diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 9a58beb3d7..ff9baf8971 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -132,6 +132,7 @@ class Q_OPENGL_EXPORT QGLWidgetPrivate : public QWidgetPrivate public: QGLWidgetPrivate() : QWidgetPrivate() , disable_clear_on_painter_begin(false) + , parent_changing(false) { } @@ -142,7 +143,7 @@ public: bool renderCxPm(QPixmap *pixmap); void cleanupColormaps(); void aboutToDestroy() { - if (glcx) + if (glcx && !parent_changing) glcx->reset(); } @@ -153,6 +154,7 @@ public: QGLColormap cmap; bool disable_clear_on_painter_begin; + bool parent_changing; }; // QGLContextPrivate has the responsibility of creating context groups. diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index f3388ee5ef..6e698bf939 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -362,6 +362,15 @@ void QGLWidgetPrivate::cleanupColormaps() bool QGLWidget::event(QEvent *e) { + Q_D(QGLWidget); + + // A re-parent will destroy the window and re-create it. We should not reset the context while it happens. + if (e->type() == QEvent::ParentAboutToChange) + d->parent_changing = true; + + if (e->type() == QEvent::ParentChange) + d->parent_changing = false; + return QWidget::event(e); } |