aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickpopup.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-26 21:31:03 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-27 13:20:20 +0000
commita7e39a28575dc3421970e007b78731b614da258a (patch)
treeb6fb24d01f6eca329b0e47a91898c93620809335 /src/quicktemplates2/qquickpopup.cpp
parente711ce99c8cafe2e7c1d81a20a280f3029c98ccb (diff)
QQuickPopup: fix binding loops with size-dependent positioning
Dependencies between popup's size and position easily lead to recursion into reposition(). Blocking recursive reposition() calls messes up the positioning, so schedule polish events instead. Task-number: QTBUG-56755 Change-Id: I72afd14573e5cd57f8162df04e193d4c42fd7236 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpopup.cpp')
-rw-r--r--src/quicktemplates2/qquickpopup.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 124b8c5b..d343fad6 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -128,6 +128,7 @@ QQuickPopupPrivate::QQuickPopupPrivate()
, hasDim(false)
, visible(false)
, complete(false)
+ , positioning(false)
, hasWidth(false)
, hasHeight(false)
, hasTopMargin(false)
@@ -401,6 +402,12 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
// connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents);
}
+void QQuickPopupItem::updatePolish()
+{
+ Q_D(QQuickPopupItem);
+ return QQuickPopupPrivate::get(d->popup)->reposition();
+}
+
bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event)
{
Q_D(QQuickPopupItem);
@@ -594,6 +601,11 @@ void QQuickPopupPrivate::reposition()
if (!popupItem->isVisible())
return;
+ if (positioning) {
+ popupItem->polish();
+ return;
+ }
+
const qreal w = popupItem->width();
const qreal h = popupItem->height();
const qreal iw = popupItem->implicitWidth();
@@ -702,6 +714,8 @@ void QQuickPopupPrivate::reposition()
}
}
+ positioning = true;
+
popupItem->setPosition(rect.topLeft());
const QPointF effectivePos = parentItem ? parentItem->mapFromScene(rect.topLeft()) : rect.topLeft();
@@ -718,6 +732,8 @@ void QQuickPopupPrivate::reposition()
popupItem->setWidth(rect.width());
if (!hasHeight && heightAdjusted && rect.height() > 0)
popupItem->setHeight(rect.height());
+
+ positioning = false;
}
void QQuickPopupPrivate::resizeOverlay()