Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.8
-
None
-
-
27a3229626249a100d8e6fa495927715aba6963d
Description
If you connect using the PMF-based API and disconnect using strings, then you will silently get a memory leak:
For instance code like this will just leak memory indefinitely:
MyQObject *o2 = new MyQObject; MyQObject *o1 = new MyQObject; forever { QObject::connect(o2, &QObject::destroyed, o1, &MyQObject::testSlot); o2->disconnect(o1, SLOT(testSlot(QObject*))); }
This is an easy trap to fall into, especially when porting existing string-based code to use the new API and finding that there is no equivalent for all the function calls. And it was recently the cause of a memory leak in Qt itself.
There currently does not appear to be any mention of this in the documentation, so there should probably be warnings in all relevant places that the syntaxes need to match and the application should ideally pick either one or the other.