Only emit messageChanged() if the message has actually changed
This fixes QStatusBar so it is back to the original behavior of only emitting the signal when the message has changed. The intention of the code that caused this to break in the first place is kept intact. Change-Id: I2f57c2abec01246ed924626ad954ac9ff9889855 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
4684f2179b
commit
89c01c3242
@ -551,8 +551,6 @@ void QStatusBar::showMessage(const QString &message, int timeout)
|
||||
{
|
||||
Q_D(QStatusBar);
|
||||
|
||||
d->tempItem = message;
|
||||
|
||||
if (timeout > 0) {
|
||||
if (!d->timer) {
|
||||
d->timer = new QTimer(this);
|
||||
@ -563,6 +561,9 @@ void QStatusBar::showMessage(const QString &message, int timeout)
|
||||
delete d->timer;
|
||||
d->timer = 0;
|
||||
}
|
||||
if (d->tempItem == message)
|
||||
return;
|
||||
d->tempItem = message;
|
||||
|
||||
hideOrShow();
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ private slots:
|
||||
void task194017_hiddenWidget();
|
||||
void QTBUG4334_hiddenOnMaximizedWindow();
|
||||
void QTBUG25492_msgtimeout();
|
||||
void messageChangedSignal();
|
||||
|
||||
private:
|
||||
QStatusBar *testWidget;
|
||||
@ -95,6 +96,8 @@ void tst_QStatusBar::init()
|
||||
|
||||
QWidget *item1 = new QWidget(testWidget);
|
||||
testWidget->addWidget(item1);
|
||||
// currentMessage needs to be null as the code relies on this
|
||||
currentMessage = QString();
|
||||
}
|
||||
|
||||
void tst_QStatusBar::cleanup()
|
||||
@ -316,6 +319,30 @@ void tst_QStatusBar::QTBUG25492_msgtimeout()
|
||||
QCOMPARE(testWidget->currentMessage(), currentMessage);
|
||||
}
|
||||
|
||||
void tst_QStatusBar::messageChangedSignal()
|
||||
{
|
||||
QVERIFY(testWidget->currentMessage().isNull());
|
||||
QVERIFY(currentMessage.isNull());
|
||||
testWidget->show();
|
||||
|
||||
QSignalSpy spy(testWidget, SIGNAL(messageChanged(QString)));
|
||||
testWidget->showMessage("Ready", 0);
|
||||
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
|
||||
QCOMPARE(testWidget->currentMessage(), currentMessage);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
|
||||
testWidget->clearMessage();
|
||||
QCOMPARE(testWidget->currentMessage(), QString());
|
||||
QCOMPARE(testWidget->currentMessage(), currentMessage);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
|
||||
testWidget->showMessage("Ready", 0);
|
||||
testWidget->showMessage("Ready", 0);
|
||||
QCOMPARE(testWidget->currentMessage(), QString("Ready"));
|
||||
QCOMPARE(testWidget->currentMessage(), currentMessage);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(spy.takeFirst().at(0).toString(), currentMessage);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QStatusBar)
|
||||
#include "tst_qstatusbar.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user