From 50523a21c960bb59405ec0ae0a9f313eefec5327 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 3 May 2012 15:48:53 +0200 Subject: [PATCH] Keep polishing until there is nothing left to polish. Some items will trigger changes in updatePolish() which again trigger property changes which needs polish to be executed again. If we do not polish until the set is fully cleared, we will end up with some items being in an unpolished state. To avoid polishing from going on indefinitely, we have a countdown that spits out a warning if polishing goes on forever. Change-Id: I4da6e884ca0d52b9b2701082ecf13e8c65508524 Reviewed-by: Aaron Kennedy --- src/quick/items/qquickcanvas.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index a6905b5..9a9a70b 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -211,14 +211,22 @@ void QQuickCanvas::focusInEvent(QFocusEvent *) void QQuickCanvasPrivate::polishItems() { - QSet itms = itemsToPolish; - itemsToPolish.clear(); + int maxPolishCycles = 100000; - for (QSet::iterator it = itms.begin(); it != itms.end(); ++it) { - QQuickItem *item = *it; - QQuickItemPrivate::get(item)->polishScheduled = false; - item->updatePolish(); + while (!itemsToPolish.isEmpty() && --maxPolishCycles > 0) { + QSet itms = itemsToPolish; + itemsToPolish.clear(); + + for (QSet::iterator it = itms.begin(); it != itms.end(); ++it) { + QQuickItem *item = *it; + QQuickItemPrivate::get(item)->polishScheduled = false; + item->updatePolish(); + } } + + if (maxPolishCycles == 0) + qWarning("QQuickCanvas: possible QQuickItem::polish() loop"); + updateFocusItemTransform(); } -- 2.7.4