From 8a4af9e87704f7b8ed269114d3ab75430bd61998 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 20 Sep 2016 16:23:57 +0200 Subject: QQuickPopup: fix negative margins The documentation states: A popup with negative margins is not pushed within the bounds of the enclosing window. Therefore QQuickPopupPrivate::reposition() must not subtract negative margins to calculate the available bounds. Change-Id: I626772970bf3d5d9eefbb13811ea1003a85bcf0b Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickpopup.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2/qquickpopup.cpp') diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 8c0e5990..2a48473a 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -595,7 +595,10 @@ void QQuickPopupPrivate::reposition() if (window) { const QMarginsF margins = getMargins(); - const QRectF bounds = QRectF(0, 0, window->width(), window->height()).marginsRemoved(margins); + const QRectF bounds(qMax(0.0, margins.left()), + qMax(0.0, margins.top()), + window->width() - qMax(0.0, margins.left()) - qMax(0.0, margins.right()), + window->height() - qMax(0.0, margins.top()) - qMax(0.0, margins.bottom())); // if the popup doesn't fit horizontally inside the window, try flipping it around (left <-> right) if (allowHorizontalFlip && (rect.left() < bounds.left() || rect.right() > bounds.right())) { -- cgit v1.2.3