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

Philipp Kursawe phil.kursawe at gmail.com
Sun Sep 8 23:55:15 CEST 2013


Well, my example was not complete.Of course the lambda code does
something in real. The problem seems to be, that Qt by itself does not
delete lambda based connections properly.




On Tue, Sep 3, 2013 at 8:19 PM, Thiago Macieira
<thiago.macieira at intel.com> wrote:
> 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
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



More information about the Interest mailing list