QQuickWidget: handle resize to empty size
authorPaul Olav Tvete <paul.tvete@digia.com>
Fri, 7 Mar 2014 15:46:51 +0000 (16:46 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 10 Mar 2014 09:34:59 +0000 (10:34 +0100)
Resizing to an empty size needs to be handled as if the widget was
hidden. Restoring to a non-empty size is like a show, except that we
are rendering synchronously.

Task-number: QTBUG-37046
Change-Id: I572e4763c4a28bfe7347868e109acca5b357db50
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
src/quickwidgets/qquickwidget.cpp
src/quickwidgets/qquickwidget_p.h

index f25f9a2..5f470e4 100644 (file)
@@ -98,6 +98,7 @@ QQuickWidgetPrivate::QQuickWidgetPrivate()
     , updateTimer(0)
     , eventPending(false)
     , updatePending(false)
+    , fakeHidden(false)
 {
     renderControl = new QQuickRenderControl;
     offscreenWindow = new QQuickWindow(renderControl);
@@ -713,6 +714,19 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
     if (d->resizeMode == SizeRootObjectToView)
         d->updateSize();
 
+    if (e->size().isEmpty()) {
+        //stop rendering
+        QQuickWindowPrivate::get(d->offscreenWindow)->forceRendering = false;
+        d->fakeHidden = true;
+        return;
+    }
+    if (d->fakeHidden) {
+        //restart rendering
+        QQuickWindowPrivate::get(d->offscreenWindow)->forceRendering = true;
+        d->fakeHidden = false;
+        d->renderControl->sync();
+    }
+
     d->createContext();
     createFramebufferObject();
     d->offscreenWindow->resizeEvent(e);
index 1d0b4e1..2d2d650 100644 (file)
@@ -114,6 +114,7 @@ public:
     int updateTimer;
     bool eventPending;
     bool updatePending;
+    bool fakeHidden;
 };
 
 QT_END_NAMESPACE