summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-11 16:30:54 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-11 16:30:54 (GMT)
commit2d63f8fe5b77747014e1c5807c9d457611bd9304 (patch)
tree12f2a2efcb619e58b0089e59d3efeff50326e720
parent46a3e518b3070cf7cb4cbbb2cb58254454cf169d (diff)
downloadQt-2d63f8fe5b77747014e1c5807c9d457611bd9304.zip
Qt-2d63f8fe5b77747014e1c5807c9d457611bd9304.tar.gz
Qt-2d63f8fe5b77747014e1c5807c9d457611bd9304.tar.bz2
Fixed: QFontComboBox emits the currentFontChanged() signal twice
Task-number: QTBUG-2438 Reviewed-by: Thierry
-rw-r--r--src/gui/widgets/qfontcombobox.cpp4
-rw-r--r--tests/auto/qfontcombobox/tst_qfontcombobox.cpp6
2 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/gui/widgets/qfontcombobox.cpp
index a66657d..d601f81 100644
--- a/src/gui/widgets/qfontcombobox.cpp
+++ b/src/gui/widgets/qfontcombobox.cpp
@@ -427,8 +427,10 @@ void QFontComboBox::setCurrentFont(const QFont &font)
Q_D(QFontComboBox);
if (font != d->currentFont) {
d->currentFont = font;
- emit currentFontChanged(d->currentFont);
d->_q_updateModel();
+ if (d->currentFont == font) { //else the signal has already be emitted by _q_updateModel
+ emit currentFontChanged(d->currentFont);
+ }
}
}
diff --git a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
index 7045c19..b974ecab 100644
--- a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
+++ b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp
@@ -153,7 +153,7 @@ void tst_QFontComboBox::currentFont()
if (oldCurrentFont != box.currentFont()) {
//the signal may be emit twice if there is a foundry into brackets
- QVERIFY(spy0.count() >= 1);
+ QCOMPARE(spy0.count(),1);
}
}
@@ -286,6 +286,10 @@ void tst_QFontComboBox::currentFontChanged()
if (box.model()->rowCount() > 2) {
QTest::keyPress(&box, Qt::Key_Down);
QCOMPARE(spy0.count(), 1);
+
+ QFont f( "Sans Serif" );
+ box.setCurrentFont(f);
+ QCOMPARE(spy0.count(), 2);
} else
qWarning("Not enough fonts installed on test system. Consider adding some");
}