summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-01-21 13:50:18 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-01-27 12:25:03 +0100
commit15b61e00c501f0e70aa70a15131d22b2ea8c80c5 (patch)
tree0a601d044f4a865417f1e9ce52ce04a7bf260ffc /src/opengl
parent475e7fed11113c8ca9724cc31052ee57e30ce97e (diff)
Fix regression with closing and then reopening widgets with QGLWidget
Amends 009abcd7b66738bece6cf354776dfb2ef401636b Calling QWidget::destroy() on SurfaceAboutToBeDestroyed has a bad side effect on QGLWidget, because QGLWidget is one of the widgets (or in fact the only widget?) that reimplements QWidgetPrivate::aboutToDestroy() and resets the OpenGL context in there (except certain conditions etc.). If now the window with the QGLWidget is shown again, it will crash as the QGLWidget is in an invalid state, given that nothing leads to reinitialization upon the show (which would be incorrect anyway since we cannot just lose the OpenGL context and then create a new one) So do the simple solution: pass on the destroyWindow flag from destroy() to the aboutToDestroy() virtual function, so the reimplementation can decide what to do. Fixes: QTBUG-86582 Change-Id: I67bb5f2690927ad62fc041793fbea4ebe6509da4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl_p.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index b3787f1e70..c6e2604227 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -140,8 +140,8 @@ public:
void initContext(QGLContext *context, const QGLWidget* shareWidget);
bool renderCxPm(QPixmap *pixmap);
void cleanupColormaps();
- void aboutToDestroy() override {
- if (glcx && !parent_changing)
+ void aboutToDestroy(bool destroyWindow) override {
+ if (glcx && !parent_changing && destroyWindow)
glcx->reset();
}