aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets/qquickwidget.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-08-28 12:23:46 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-08-29 23:19:18 +0200
commitc2db9b6a48ac979057be640013655c815a153e21 (patch)
treedb73f7fd64bccb788de0e75d87c57d0332f5dd39 /src/quickwidgets/qquickwidget.cpp
parenta23ee5c0de0d91859e1e76e64073861347dd9861 (diff)
QQuickWidget: Keep the offscreen quick window size in sync
The resizing logic has some faults: The size change is not always communicated to the offscreen QQuickWindow. When hiding and showing a QQuickWidget we may return early from the resize event handler, skipping the geometry change for the offscreen window. This is wrong. To make sure the sizes always match, set the geometry together with the FBO creation instead. This is much more robust and guarantees that the FBO size and the QQuickWindow size will not be out of sync. Task-number: QTBUG-40517 Change-Id: I61ef3ad2d23dff4280dbf03b57c03c1aeda8dc91 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/quickwidgets/qquickwidget.cpp')
-rw-r--r--src/quickwidgets/qquickwidget.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index e85b0fe2e0..285b000bdc 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -703,8 +703,13 @@ void QQuickWidget::createFramebufferObject()
QSize fboSize = size() * window()->devicePixelRatio();
- delete d->fbo;
- d->fbo = new QOpenGLFramebufferObject(fboSize, format);
+ // Could be a simple hide - show, in which case the previous fbo is just fine.
+ if (!d->fbo || d->fbo->size() != fboSize) {
+ delete d->fbo;
+ d->fbo = new QOpenGLFramebufferObject(fboSize, format);
+ }
+
+ d->offscreenWindow->setGeometry(0, 0, width(), height());
d->offscreenWindow->setRenderTarget(d->fbo);
if (samples > 0)
@@ -891,8 +896,8 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
}
if (d->context) {
- // Bail out in the special case of receiving a resize after
- // scenegraph invalidation during application exit.
+ // Bail out when receiving a resize after scenegraph invalidation. This can happen
+ // during hide - resize - show sequences and also during application exit.
if (!d->fbo && !d->offscreenWindow->openglContext())
return;
if (!d->fbo || d->fbo->size() != size() * devicePixelRatio()) {
@@ -906,9 +911,6 @@ void QQuickWidget::resizeEvent(QResizeEvent *e)
d->createContext();
}
- QCoreApplication::sendEvent(d->offscreenWindow, e);
- d->offscreenWindow->setGeometry(0, 0, e->size().width(), e->size().height());
-
QOpenGLContext *context = d->offscreenWindow->openglContext();
if (!context) {
qWarning("QQuickWidget::resizeEvent() no OpenGL context");