sender null on functor receiver of connect(const QObject *sender, PointerToMemberFunction signal, Functor functor) ? :'(
-
Hi,
I'm doing this kind of connectionconnect(this, &ScopedSignal::scopedSignalReply, m_receivingSlot);
with m_receivingSlot being of type:std::function<void()>
initialized with:std::bind(&NotificationList::onNotificationsReadReply, this)
and my receiving slot:
void NotificationList::onNotificationsReadReply() { QObject * s = sender(); ... }
My sender is null :(
I need it as it is the key of a Map where I should delete the associated service...
Any idea? -
Then use a simple lambda function
connect(this, &ScopedSignal::scopedSignalReply, this, [this]() { onNotificationsReadReply(this); }
-
@Christian-Ehrlicher great this does the job perfectly! \o/ I've extra parameters in my lambda but that a great workaround.
I still would like to understand why the sender is null.
I've never checked the underlying code of functor connection but I would expect it should be able to retrieve the sender...
Anybody else had this issue?
Is it something specific to the functor signature that is processed just like a C callback maybe?
Interesting to know about no? -
@Christian-Ehrlicher great this does the job perfectly! \o/ I've extra parameters in my lambda but that a great workaround.
I still would like to understand why the sender is null.
I've never checked the underlying code of functor connection but I would expect it should be able to retrieve the sender...
Anybody else had this issue?
Is it something specific to the functor signature that is processed just like a C callback maybe?
Interesting to know about no? -
@Christian-Ehrlicher great this does the job perfectly! \o/ I've extra parameters in my lambda but that a great workaround.
I still would like to understand why the sender is null.
I've never checked the underlying code of functor connection but I would expect it should be able to retrieve the sender...
Anybody else had this issue?
Is it something specific to the functor signature that is processed just like a C callback maybe?
Interesting to know about no?@mbruel31 said in sender null on functor receiver of connect(const QObject *sender, PointerToMemberFunction signal, Functor functor) ? :'(:
Is it something specific to the functor signature that is processed just like a C callback maybe?
To few information - it can be e.q. a QueuedConnection due to thread context switch or similar.