Destroy the FBO in QQuickWidget while a context is current
authorLaszlo Agocs <laszlo.agocs@digia.com>
Mon, 2 Jun 2014 08:21:56 +0000 (10:21 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 3 Jun 2014 08:34:35 +0000 (10:34 +0200)
When creating the new FBO, it will try to restore the previous FBO
after initialization. The internal tracking of the current FBO goes
horribly wrong when a QOpenGLFramebufferObject is destroyed with
no context current. In 5.4 the problem is solved by removing the
tracking altogether. Here QQuickWidget is fixed to play nice and
destroy QOpenGLFramebufferObject always with the context current.

Task-number: QTBUG-39389
Change-Id: Ic6917696ed61f284d661a578c9c7f2e0673c412d
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
src/quickwidgets/qquickwidget.cpp

index aea21af..ec5d0bf 100644 (file)
@@ -657,8 +657,6 @@ void QQuickWidget::createFramebufferObject()
 {
     Q_D(QQuickWidget);
 
-    if (d->fbo)
-        delete d->fbo;
     QOpenGLContext *context = d->offscreenWindow->openglContext();
 
     if (!context) {
@@ -672,6 +670,8 @@ void QQuickWidget::createFramebufferObject()
     }
 
     context->makeCurrent(d->offscreenSurface);
+
+    delete d->fbo;
     d->fbo = new QOpenGLFramebufferObject(size() * window()->devicePixelRatio());
     d->fbo->setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
     d->offscreenWindow->setRenderTarget(d->fbo);