Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.0.0
-
None
-
Windows 7 x64
vs2010
-
b188d9481b98680deb7f44fb41f8eafce18aedab
Description
The following code can demonstrate this leak:
int main(int argc, char *argv[]) { QApplication a(argc, argv); QGLWidget w; w.show(); int ret = a.exec(); int nCrtDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); nCrtDbgFlag |= _CRTDBG_LEAK_CHECK_DF; _CrtSetDbgFlag(nCrtDbgFlag); return ret; }
Run this program in debug mode (Press F5), and you can see memory leak report at exit.
The leaked object is QOpenGLContextGroup object. Since QOpenGLContextGroup object
is desgned to be destroyed by deleteLater(), but this method will not always work due to the fact
that in many cases event loop will exit before the deferred deletion of the QOpenGLContextGroup
object is queued. As we can see in the above program, the event loop will exit before QGLWidget object's
destruction. This will cause the QOpenGLContextGroup object hold by QGLWidget object never been deleted.