From f3aad61120d5cc8029c7092b1f74e2b5b632f99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 14 May 2013 13:50:31 +0200 Subject: Fixed crash associated with reparenting a QGLWidget We need to make sure that we don't reset() the context when the QGLWidget is being reparented, as that will lead to the QOpenGLContext being destroyed and not recreated, leading to a crash in makeCurrent(). Also, don't destroy() the widget if it has not yet been created, as in that case there's no ParentAboutToChange event sent. Task-number: QTBUG-31016 Change-Id: I409fff94456802a80bd72b470a6fbaee87505baa Reviewed-by: Friedemann Kleint Reviewed-by: Andy Nichols --- src/opengl/qgl_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/opengl/qgl_p.h') 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. -- cgit v1.2.3