[Interest] Fwd: Lambda based connections are not disconnected upon QObject deletion
Constantin Makshin
cmakshin at gmail.com
Tue Sep 3 19:55:08 CEST 2013
The connection in your example doesn't use 'obj' at all (there are no
non-static overloads of connect() that allow binding to lambda
functions), so the crash can't be caused by deletion of that object.
On 09/03/2013 11:58 AM, Philipp Kursawe wrote:
> Using this code:
>
> @
> obj->connect(sender, &Sender::signal, [] {
> });
>
> // later
> obj->deleteLater();
> @
>
> The object will be deleted, but the connection will not be broken, and
> the sender can still signal, the lambda will be called, but of course
> it will crash. Is this a known limitation of using lambdas?
>
> I know I could remember the connection and call
> disconnect(connectionId) in my Objects dtor, but this manual work can
> be easily overlooked
>
> Any ideas?
>
> Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130903/5c081f20/attachment.sig>
More information about the Interest
mailing list