QStatusBar::showMessage will always take new timeout

There is a message check in QStatusBar::showMessage causing the call exits
early if the new 'message' is the same
as the current message. The check has been removed, and new timeout will
always take effect. Unit test is added as well.

Change-Id: I3a03c6842835824caba4adc37c3ed834952c4bb2
Task-Id: QTBUG-25492
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
This commit is contained in:
Jiewen Wang 2012-05-25 08:13:11 -04:00 committed by Qt by Nokia
parent 2848395b50
commit 7381328bcc
2 changed files with 45 additions and 2 deletions

View File

@ -546,8 +546,6 @@ void QStatusBar::reformat()
void QStatusBar::showMessage(const QString &message, int timeout)
{
Q_D(QStatusBar);
if (d->tempItem == message)
return;
d->tempItem = message;

View File

@ -73,6 +73,7 @@ private slots:
void setSizeGripEnabled();
void task194017_hiddenWidget();
void QTBUG4334_hiddenOnMaximizedWindow();
void QTBUG25492_msgtimeout();
private:
QStatusBar *testWidget;
@ -276,5 +277,49 @@ void tst_QStatusBar::QTBUG4334_hiddenOnMaximizedWindow()
QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible());
}
void tst_QStatusBar::QTBUG25492_msgtimeout()
{
QVERIFY(testWidget->currentMessage().isNull());
QVERIFY(currentMessage.isNull());
testWidget->show();
// Set display message forever first
testWidget->showMessage("Ready", 0);
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(1000);
// Set display message for 2 seconds again
testWidget->showMessage("Ready", 2000);
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(3000);
// Message disappears after 2 seconds
QVERIFY(testWidget->currentMessage().isNull());
QVERIFY(currentMessage.isNull());
// Set display message for 2 seconds first
testWidget->showMessage("Ready 25492", 2000);
QCOMPARE(testWidget->currentMessage(), QString("Ready 25492"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(1000);
// Set display message forever again
testWidget->showMessage("Ready 25492", 0);
QCOMPARE(testWidget->currentMessage(), QString("Ready 25492"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
QTest::qWait(3000);
// Message displays forever
QCOMPARE(testWidget->currentMessage(), QString("Ready 25492"));
QCOMPARE(testWidget->currentMessage(), currentMessage);
}
QTEST_MAIN(tst_QStatusBar)
#include "tst_qstatusbar.moc"