From e78274d5f8c0eb5c10b9b58e069b90b6475c6f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 10 Sep 2010 15:35:34 +0200 Subject: Prevented crash in GL window surface when deleting native child widgets. We should only destroy the FBO if it's the actual window that's deleted. Reviewed-by: Trond --- src/opengl/qwindowsurface_gl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 48c7deb..f98dcff 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -345,12 +345,14 @@ QGLWindowSurface::~QGLWindowSurface() void QGLWindowSurface::deleted(QObject *object) { - // Make sure that the fbo is destroyed before destroying its context. - delete d_ptr->fbo; - d_ptr->fbo = 0; - QWidget *widget = qobject_cast(object); if (widget) { + if (widget == window()) { + // Make sure that the fbo is destroyed before destroying its context. + delete d_ptr->fbo; + d_ptr->fbo = 0; + } + QWidgetPrivate *widgetPrivate = widget->d_func(); if (widgetPrivate->extraData()) { union { QGLContext **ctxPtr; void **voidPtr; }; @@ -422,6 +424,8 @@ QPaintDevice *QGLWindowSurface::paintDevice() QGLContext *ctx = reinterpret_cast(window()->d_func()->extraData()->glContext); ctx->makeCurrent(); + + Q_ASSERT(d_ptr->fbo); return d_ptr->fbo; } -- cgit v0.12