diff options
author | Wang Chuan <ouchuanm@outlook.com> | 2019-12-13 21:50:03 +0800 |
---|---|---|
committer | ouchuan <ouchuanm@outlook.com> | 2020-01-11 22:13:09 +0800 |
commit | f4d5939ad613fda69aa750139ef929fac18b97ae (patch) | |
tree | 6de8482908da3e7d591ef506b927ba2aa3e0f455 /tests/auto/qquickpopup/tst_qquickpopup.cpp | |
parent | 090eab86b05478572485b3086c087a846fbae7fd (diff) |
QQuickToolTip: prevent closing after invisible tooltip created
Since all items using ToolTip attached property share the same ToolTip
item, a dynamically created invisible Tooltip may unexpectedly close
the current visible ToolTip.
Fix this issue by checking the parent of ToolTip when trying to close
it
Fixes: QTBUG-78202
Change-Id: I0f6558040c6b8bf22240b0c94af912a43d525ed9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/qquickpopup/tst_qquickpopup.cpp')
-rw-r--r-- | tests/auto/qquickpopup/tst_qquickpopup.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp index e852a61e..f55d42bc 100644 --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -93,6 +93,7 @@ private slots: void countChanged(); void toolTipCrashOnClose(); void setOverlayParentToNull(); + void invisibleToolTipOpen(); }; void tst_QQuickPopup::initTestCase() @@ -1299,6 +1300,33 @@ void tst_QQuickPopup::setOverlayParentToNull() // While nullifying the overlay parent doesn't make much sense, it shouldn't crash. } +void tst_QQuickPopup::invisibleToolTipOpen() +{ + QQuickApplicationHelper helper(this, "invisibleToolTipOpen.qml"); + + QQuickWindow *window = helper.window; + centerOnScreen(window); + moveMouseAway(window); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickItem *mouseArea = qvariant_cast<QQuickItem *>(window->property("mouseArea")); + QVERIFY(mouseArea); + QObject *loader = qvariant_cast<QObject *>(window->property("loader")); + QVERIFY(loader); + + QTest::mouseMove(window, QPoint(mouseArea->width() / 2, mouseArea->height() / 2)); + QTRY_VERIFY(mouseArea->property("isToolTipVisible").toBool()); + + QSignalSpy componentLoadedSpy(loader, SIGNAL(loaded())); + QVERIFY(componentLoadedSpy.isValid()); + + loader->setProperty("active", true); + QTRY_COMPARE(componentLoadedSpy.count(), 1); + + QTRY_VERIFY(mouseArea->property("isToolTipVisible").toBool()); +} + QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup) #include "tst_qquickpopup.moc" |