Fix segfault on certain resize patterns in QQuickWidget
authorLaszlo Agocs <laszlo.agocs@digia.com>
Tue, 1 Jul 2014 09:36:33 +0000 (11:36 +0200)
committerLaszlo Agocs <laszlo.agocs@digia.com>
Mon, 7 Jul 2014 08:04:53 +0000 (10:04 +0200)
Resizing to an empty size followed by another resize leads to
sync() without having the context and the render control intialized.
This is wrong.

Task-number: QTBUG-39858
Change-Id: I5908723272165a656d192644cceb16ed253e6d3b
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
src/quickwidgets/qquickwidget.cpp

index fc6d39e..91f4ac4 100644 (file)
@@ -869,7 +869,7 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
         d->fakeHidden = true;
         return;
     }
-    if (d->fakeHidden) {
+    if (d->fakeHidden && d->context) {
         //restart rendering
         d->fakeHidden = false;
         d->renderControl->sync();
@@ -887,7 +887,14 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
     }
 
     context->makeCurrent(d->offscreenSurface);
+
+    if (d->fakeHidden) {
+        d->fakeHidden = false;
+        d->renderControl->sync();
+    }
+
     d->renderControl->render();
+
     context->functions()->glFlush();
     context->doneCurrent();
 }