Can someone explain (QThread and QThreadPrivate)
I was monitoring my app for leaks etc ... and a leak indication came up at QThread. So i looked to the constructor etc ... and found this piece of code in it.
: QObject((new QThreadPrivate), parent)
Looking at QObject:
QObject::QObject(QObjectPrivate &dd, QObject *parent)
at QObject the d_ptr never gets a cleanup.
But at QThread the new QThreadPrivate is never cleaned up either...
So, as this is a core class and alot of people are using it. It can't really be a leak (i assume) as this would be detected already a long time ago... but i can't really find anything related to this subject...
So is there someone willing to explain? Or give an opinion on this matter?
The d_ptr is not stored as a raw pointer, but as a QScopedPointer in QObject. QScopedPointer will take care of the deletion when it goes out of scope, that is, when the QObject is deleted.
See the qobject.h file, around line 450 (Qt 5.3.1, may be different for other Qt versions).
Oh, i overlooked that!
Thank you for that answer!