summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2019-08-26 17:56:43 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2019-09-27 15:33:32 +0300
commit100550dd22dc8eaa47405cdb3e7e461edb01a7a3 (patch)
tree83c7aa041db43bbd1ee569a1f4947b6cb339927e
parentd39a6d80f63414a4e933ac2f859805635850942a (diff)
QQuickToolTip: fix setTimeout() behavior when tool tip is visible
by applying the passed timeout value prior to re-starting the timer Change-Id: I27953dbb4781b5cb0c2039d56faa56f3c000206f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp3
-rw-r--r--tests/auto/controls/data/tst_tooltip.qml9
2 files changed, 11 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index c1271dab..0a36e0c7 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -238,12 +238,13 @@ void QQuickToolTip::setTimeout(int timeout)
if (d->timeout == timeout)
return;
+ d->timeout = timeout;
+
if (timeout <= 0)
d->stopTimeout();
else if (isVisible())
d->startTimeout();
- d->timeout = timeout;
emit timeoutChanged();
}
diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml
index 18911895..70579c70 100644
--- a/tests/auto/controls/data/tst_tooltip.qml
+++ b/tests/auto/controls/data/tst_tooltip.qml
@@ -205,6 +205,15 @@ TestCase {
else
control.visible = true
compare(control.visible, true)
+ // wait a bit to make sure that it's still visible
+ wait(50)
+ compare(control.visible, true)
+ // re-arm for another 200 ms
+ control.timeout = 200
+ compare(control.visible, true)
+ // ensure that it's still visible after 150 ms (where old timeout < 150 < new timeout)
+ wait(150)
+ compare(control.visible, true)
tryCompare(control, "visible", false)
}