From deb322f3f358b0e596720f85361a0e7077137530 Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Thu, 17 Sep 2009 15:07:03 +0200 Subject: Fixed a bug in QToolTip when internal tool tips where reused. If a tool tip is to be reused, it *has* to be visible otherwise it *may* get destroyed by the expiration timer before the timer is reset. The tst_qtooltip::setPalette() test triggered this obscure bug under Windows. Reviewed-by: Kim --- src/gui/kernel/qtooltip.cpp | 6 +++--- tests/auto/qtooltip/tst_qtooltip.cpp | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qtooltip.cpp b/src/gui/kernel/qtooltip.cpp index a480195..2d0d209 100644 --- a/src/gui/kernel/qtooltip.cpp +++ b/src/gui/kernel/qtooltip.cpp @@ -290,8 +290,8 @@ void QTipLabel::timerEvent(QTimerEvent *e) // Fade out tip on mac (makes it invisible). // The tip will not be deleted until a new tip is shown. - // DRSWAT - Cocoa - macWindowFade(qt_mac_window_for(this)); + // DRSWAT - Cocoa + macWindowFade(qt_mac_window_for(this)); QTipLabel::instance->fadingOut = true; // will never be false again. } else @@ -431,7 +431,7 @@ bool QTipLabel::tipChanged(const QPoint &pos, const QString &text, QObject *o) void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect) { - if (QTipLabel::instance){ // a tip does already exist + if (QTipLabel::instance && QTipLabel::instance->isVisible()){ // a tip does already exist if (text.isEmpty()){ // empty text means hide current tip QTipLabel::instance->hideTip(); return; diff --git a/tests/auto/qtooltip/tst_qtooltip.cpp b/tests/auto/qtooltip/tst_qtooltip.cpp index 5068460..2ad74a3 100644 --- a/tests/auto/qtooltip/tst_qtooltip.cpp +++ b/tests/auto/qtooltip/tst_qtooltip.cpp @@ -42,6 +42,7 @@ #include #include +#include "../../shared/util.h" //TESTED_CLASS= //TESTED_FILES= @@ -132,20 +133,24 @@ void tst_QToolTip::task183679() void tst_QToolTip::setPalette() { //the previous test may still have a tooltip pending for deletion - QTest::qWait(100); QVERIFY(!QToolTip::isVisible()); QToolTip::showText(QPoint(), "tool tip text", 0); - QTest::qWait(100); + + QTRY_VERIFY(QToolTip::isVisible()); QWidget *toolTip = 0; foreach (QWidget *widget, QApplication::topLevelWidgets()) { - if (widget->windowType() == Qt::ToolTip) { + if (widget->windowType() == Qt::ToolTip + && widget->objectName() == QLatin1String("qtooltip_label")) + { toolTip = widget; break; } } + QVERIFY(toolTip); + QTRY_VERIFY(toolTip->isVisible()); const QPalette oldPalette = toolTip->palette(); QPalette newPalette = oldPalette; -- cgit v0.12