aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-08-05 17:16:56 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-08-06 10:27:26 +0200
commit14b4747b17d522fe57f3a5f21738c5a89323b5e2 (patch)
treee209b2627f4728bba0e77d94ce86ab46c9a994c3
parent2121de6d8762ec2fc90a07e207824090e8447291 (diff)
Fix fbo creation and resize logic in QQuickWidget
This corrects two issues: 1. Recreating the fbo twice when the widget is shown. Calling createFramebufferObject() is not necessary in this case since createContext() will trigger this anyhow due to scenegraphInitialized(). 2. Avoid recreating the fbo when the size is the same as before. Some platforms are keen on sending resize events with the same size. These should be ignored. What's worse, some platforms (cocoa) generate a resize on exitting (Cmd-Q) and not ignoring the resize at that stage is dangerous since the scenegraph is already invalidated. Task-number: QTBUG-40505 Change-Id: I21ff418fde449aa15eef4d6593e7a518861fcde1 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
-rw-r--r--src/quickwidgets/qquickwidget.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 5e1502b633..77d16222d2 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -875,8 +875,19 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
d->renderControl->sync();
}
- d->createContext();
- createFramebufferObject();
+ if (d->context) {
+ // Bail out in the special case of receiving a resize after
+ // scenegraph invalidation during application exit.
+ if (!d->fbo && !d->offscreenWindow->openglContext())
+ return;
+ if (!d->fbo || d->fbo->size() != size() * devicePixelRatio())
+ createFramebufferObject();
+ } else {
+ // This will result in a scenegraphInitialized() signal which
+ // is connected to createFramebufferObject().
+ d->createContext();
+ }
+
d->offscreenWindow->resizeEvent(e);
d->offscreenWindow->setGeometry(0, 0, e->size().width(), e->size().height());