aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets/qquickwidget.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-08-14 12:58:55 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-08-14 15:58:45 +0200
commitddb134af9903512408b7e52455f1787e4b6b62ea (patch)
treeb4ad1bb20aa7ee322ccd283876eb8d4625652ab8 /src/quickwidgets/qquickwidget.cpp
parentccb1eb743d11e7e6658e6ad72c12b39d39b4c9eb (diff)
Fix flicker when showing QQuickWidget
This also reintroduces the change from commit 14b4747b17d522fe57f3a5f21738c5a89323b5e2. Due to some bizarre merge issue that change has disappeared from qquickwidget.cpp and its history. It is there in the main log, though. The new fix depends on this older one, so the combined one fixes the following three issues: 1. Polish and sync cannot be skipped when we are rendering for the first time. 2. 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(). 3. 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-40710 Task-number: QTBUG-40505 Change-Id: I2e897acc68fa68233563a1db63ffb6c5d0baad73 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
-rw-r--r--src/quickwidgets/qquickwidget.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 446ed1c84e..b89c894cb2 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -891,8 +891,23 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
d->renderControl->sync();
}
- d->createContext();
- createFramebufferObject();
+ bool newFbo = false;
+ 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()) {
+ newFbo = true;
+ createFramebufferObject();
+ }
+ } else {
+ // This will result in a scenegraphInitialized() signal which
+ // is connected to createFramebufferObject().
+ newFbo = true;
+ d->createContext();
+ }
+
QCoreApplication::sendEvent(d->offscreenWindow, e);
d->offscreenWindow->setGeometry(0, 0, e->size().width(), e->size().height());
@@ -904,10 +919,13 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
context->makeCurrent(d->offscreenSurface);
- if (d->fakeHidden) {
- d->fakeHidden = false;
+ if (newFbo) {
+ d->renderControl->polishItems();
+ d->renderControl->sync();
+ } else if (d->fakeHidden) {
d->renderControl->sync();
}
+ d->fakeHidden = false;
d->renderControl->render();
context->functions()->glFlush();