diff options
author | Paul Olav Tvete <paul.tvete@digia.com> | 2014-03-19 09:30:05 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-19 17:24:01 +0100 |
commit | 8a0573b92924ba3fcf4228730c2c693b52c41c28 (patch) | |
tree | 954bc549db908b651aa666ad0259b337d2a334b9 | |
parent | 1145d76ebad94acee602c83b59d125337d0ff193 (diff) |
QQuickWidget: Fix SizeViewToRootObject
There were two problems: 1) QWidget does not have a default size of (0,0)
or (1,1), but uses WA_Resized. 2) event() would eat timer events without
checking the timerId.
Change-Id: I355acbb10d3d5073e117c29de18bb94857881141
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 22 | ||||
-rw-r--r-- | src/quickwidgets/qquickwidget_p.h | 2 |
2 files changed, 10 insertions, 14 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index d13a614d49..24d759ac0a 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -104,7 +104,6 @@ QQuickWidgetPrivate::QQuickWidgetPrivate() , context(0) , resizeMode(QQuickWidget::SizeViewToRootObject) , initialSize(0,0) - , updateTimer(0) , eventPending(false) , updatePending(false) , fakeHidden(false) @@ -697,7 +696,8 @@ void QQuickWidgetPrivate::setRootObject(QObject *obj) } if (root) { initialSize = rootObjectSize(); - if ((resizeMode == QQuickWidget::SizeViewToRootObject || q->width() <= 1 || q->height() <= 1) && + bool resized = q->testAttribute(Qt::WA_Resized); + if ((resizeMode == QQuickWidget::SizeViewToRootObject || !resized) && initialSize != q->size()) { q->resize(initialSize); } @@ -712,8 +712,7 @@ GLuint QQuickWidgetPrivate::textureId() const /*! \internal - If the \l {QTimerEvent} {timer event} \a e is this - view's resize timer, sceneResized() is emitted. + Handle item resize and scene updates. */ void QQuickWidget::timerEvent(QTimerEvent* e) { @@ -721,6 +720,11 @@ void QQuickWidget::timerEvent(QTimerEvent* e) if (!e || e->timerId() == d->resizetimer.timerId()) { d->updateSize(); d->resizetimer.stop(); + } else if (e->timerId() == d->updateTimer.timerId()) { + d->eventPending = false; + d->updateTimer.stop(); + if (d->updatePending) + d->renderSceneGraph(); } } @@ -912,14 +916,6 @@ bool QQuickWidget::event(QEvent *e) Q_D(QQuickWidget); switch (e->type()) { - case QEvent::Timer: - d->eventPending = false; - killTimer(d->updateTimer); - d->updateTimer = 0; - if (d->updatePending) - d->renderSceneGraph(); - return true; - case QEvent::TouchBegin: case QEvent::TouchEnd: case QEvent::TouchUpdate: @@ -946,7 +942,7 @@ void QQuickWidget::triggerUpdate() d->updatePending = true; if (!d->eventPending) { const int exhaustDelay = 5; - d->updateTimer = startTimer(exhaustDelay, Qt::PreciseTimer); + d->updateTimer.start(exhaustDelay, Qt::PreciseTimer, this); d->eventPending = true; } } diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h index 6a822ffba0..5cf2bfbf1d 100644 --- a/src/quickwidgets/qquickwidget_p.h +++ b/src/quickwidgets/qquickwidget_p.h @@ -113,7 +113,7 @@ public: QSize initialSize; QElapsedTimer frameTimer; - int updateTimer; + QBasicTimer updateTimer; bool eventPending; bool updatePending; bool fakeHidden; |