From 0bd2f8f23a9f9ec57ff17256410d87d3cfaf6274 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sat, 16 May 2020 19:44:35 +0100 Subject: [PATCH] tests: Add sanity checks for the tested rects Catches the situtions fixed in the two previous commits. --- src/private/multisplitter/Item.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/private/multisplitter/Item.cpp b/src/private/multisplitter/Item.cpp index bd507425..41a4ef55 100644 --- a/src/private/multisplitter/Item.cpp +++ b/src/private/multisplitter/Item.cpp @@ -2709,8 +2709,10 @@ bool ItemContainer::test_suggestedRect() if (auto c = relativeTo->asContainer()) { c->test_suggestedRect(); } else { + QHash rects; for (Location loc : { Location_OnTop, Location_OnLeft, Location_OnRight, Location_OnBottom}) { const QRect rect = suggestedDropRect(itemToDrop, relativeTo, loc); + rects.insert(loc, rect); if (rect.isEmpty()) { qWarning() << Q_FUNC_INFO << "Empty rect"; return false; @@ -2718,8 +2720,16 @@ bool ItemContainer::test_suggestedRect() root()->dumpLayout(); qWarning() << Q_FUNC_INFO << "Suggested rect is out of bounds" << rect << "; loc=" << loc << "; relativeTo=" << relativeTo; + return false; } } + if (rects.value(Location_OnBottom).y() <= rects.value(Location_OnTop).y() || + rects.value(Location_OnRight).x() <= rects.value(Location_OnLeft).x()) { + root()->dumpLayout(); + qWarning() << Q_FUNC_INFO << "Invalid suggested rects" << rects + << this << "; relativeTo=" << relativeTo; + return false; + } } }