From 4f6054407ab63dea424a0dd1242f5f025d7967db Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 25 Jul 2011 14:11:42 +1000 Subject: [PATCH] Update polish even when animations aren't running Task-number: QTBUG-20078 Change-Id: I095a872d72da61248794ec4a2a85f91ee618cdbc Reviewed-on: http://codereview.qt.nokia.com/2063 Reviewed-by: Aaron Kennedy --- src/declarative/items/qsgcanvas.h | 1 + src/declarative/items/qsgitem.cpp | 8 ++++-- tests/auto/declarative/qsgitem/tst_qsgitem.cpp | 38 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/declarative/items/qsgcanvas.h b/src/declarative/items/qsgcanvas.h index 0287740..a5f69ff 100644 --- a/src/declarative/items/qsgcanvas.h +++ b/src/declarative/items/qsgcanvas.h @@ -118,6 +118,7 @@ private Q_SLOTS: void maybeUpdate(); private: + friend class QSGItem; Q_DISABLE_COPY(QSGCanvas) }; diff --git a/src/declarative/items/qsgitem.cpp b/src/declarative/items/qsgitem.cpp index b4fbacb..dea0286 100644 --- a/src/declarative/items/qsgitem.cpp +++ b/src/declarative/items/qsgitem.cpp @@ -1830,8 +1830,12 @@ void QSGItem::polish() Q_D(QSGItem); if (!d->polishScheduled) { d->polishScheduled = true; - if (d->canvas) - QSGCanvasPrivate::get(d->canvas)->itemsToPolish.insert(this); + if (d->canvas) { + QSGCanvasPrivate *p = QSGCanvasPrivate::get(d->canvas); + bool maybeupdate = p->itemsToPolish.isEmpty(); + p->itemsToPolish.insert(this); + if (maybeupdate) d->canvas->maybeUpdate(); + } } } diff --git a/tests/auto/declarative/qsgitem/tst_qsgitem.cpp b/tests/auto/declarative/qsgitem/tst_qsgitem.cpp index edddbdc..e591ab8 100644 --- a/tests/auto/declarative/qsgitem/tst_qsgitem.cpp +++ b/tests/auto/declarative/qsgitem/tst_qsgitem.cpp @@ -44,7 +44,9 @@ #include "qsgitem.h" #include "qsgcanvas.h" #include "private/qsgfocusscope_p.h" +#include "../../../shared/util.h" #include +#include class TestItem : public QSGItem { @@ -62,6 +64,28 @@ protected: virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { event->accept(); ++releaseCount; } }; +class TestPolishItem : public QSGItem +{ +Q_OBJECT +public: + TestPolishItem(QSGItem *parent) + : QSGItem(parent), wasPolished(false) { + QTimer::singleShot(50, this, SLOT(doPolish())); + } + + bool wasPolished; + +protected: + virtual void updatePolish() { + wasPolished = true; + } + +public slots: + void doPolish() { + polish(); + } +}; + class TestFocusScope : public QSGFocusScope { Q_OBJECT @@ -97,6 +121,7 @@ private slots: void enabled(); void mouseGrab(); + void polishOutsideAnimation(); private: void ensureFocus(QWidget *w) { @@ -806,6 +831,19 @@ void tst_qsgitem::mouseGrab() delete canvas; } +void tst_qsgitem::polishOutsideAnimation() +{ + QSGCanvas *canvas = new QSGCanvas; + canvas->resize(200, 200); + canvas->show(); + + TestPolishItem *item = new TestPolishItem(canvas->rootItem()); + + QTRY_VERIFY(item->wasPolished); + + delete item; + delete canvas; +} QTEST_MAIN(tst_qsgitem) -- 2.7.4