[Interest] Fwd: Lambda based connections are not disconnected upon QObject deletion

Thiago Macieira thiago.macieira at intel.com
Tue Sep 3 20:19:55 CEST 2013


On terça-feira, 3 de setembro de 2013 09:39:21, Thiago Macieira wrote:
> On terça-feira, 3 de setembro de 2013 09:58:28, 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?
> 
> Huh? how can you send a signal after the sender is deleted?
> 
> deleteLater() does not mean delete *now*.

Ah, sorry, after reading Constantin's email, I see what you meant.

I took the lambda in the example to be literal. I did not see how emitting the 
signal from Sender would crash, since the lambda didn't do anything.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130903/b9307d58/attachment.sig>


More information about the Interest mailing list