diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-01-23 21:02:37 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-01-24 12:35:56 +0100 |
commit | 7414c2c404cc241b1dbfa2d15aee2917a3b0cfb2 (patch) | |
tree | ee49713c8c54863a3b3c19aeae4902cb8c8f2b30 /src/gui/kernel/qplatformopenglcontext.cpp | |
parent | dd07b1e38927d47802087c75c365f13d13a04248 (diff) |
QOpenGLWidget/QOpenGLWindow: add a destructor which calls makeCurrent
Generally speaking, QOpenGLWindow subclasses are going to use some
various QOpenGL* wrapper object to handle their buffers, FBOs, etc.
Some of those QOpenGL* wrappers are QObjects, hence it should be safe
to have them as child objects, and expect Qt to clean them up properly;
but that doesn't happen because of how the destruction will work.
In particular, when the subclass object is deleted, there may not be
the right OpenGL context set as current. The deletion will go up to
~QObject, where the child objects will be deleted, resulting in a crash.
That will *also* happen if someone connected to the context's
aboutToBeDestroyed() signal: the context will in fact be deleted
after the child objects, since it's stored in QOpenGLWindowPrivate,
whose dtor will be run after ~QObject (!).
Now, in the general case, QOpenGLWindow subclasses should always
have a dtor in which they call makeCurrent() (also because various QOpenGL*
class are not QObjects, hence they're kept around as full members
instead of pointers-to); but at the same time we should clean up
properly the QObject children.
All of the above of course stands for QOpenGLWidget as well.
Task-number: QTBUG-44094
Change-Id: I2379041fe175416936f6d40292039f773a515b35
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qplatformopenglcontext.cpp')
0 files changed, 0 insertions, 0 deletions