[Interest] Who disconnects lambda expression slots?

Nikos Chantziaras realnc at gmail.com
Sat Dec 15 01:53:58 CET 2012


Since it's now possible to use lambdas as slots:

     connect(sender, &SenderClass::connected, [this] () {
         this->doSomething();
     };

I have to wonder what is supposed to happen when the object where the 
lambda appears gets destroyed.  In this particular example, if the 
lambda executes, dereferencing 'this' is no longer valid.

The documentation:

   http://qt-project.org/doc/qt-5.0/qtcore/qobject.html#connect-5

does not mention anything about it.




More information about the Interest mailing list