diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-01 09:35:54 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-01 09:43:19 (GMT) |
commit | 4bb7bacccff707a693de6d50c7ce886126b68c25 (patch) | |
tree | de1c652674f7f373f3f07197755ea3e4d1b26c16 | |
parent | 3c1c84dd569c02bfeec66aa985616b654b69a531 (diff) | |
download | Qt-4bb7bacccff707a693de6d50c7ce886126b68c25.zip Qt-4bb7bacccff707a693de6d50c7ce886126b68c25.tar.gz Qt-4bb7bacccff707a693de6d50c7ce886126b68c25.tar.bz2 |
Fix QFontCombobox autotest on X11
On X11, Font might have a foundry within bracket.
This foundry is set by the font combobox, and makes the font
comparison fail.
Make sure the other attributes (size, bold, ...) are preserved
when the font is changed.
Reviewed-by: Gabriel
-rw-r--r-- | src/gui/widgets/qfontcombobox.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qfontcombobox/tst_qfontcombobox.cpp | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/gui/widgets/qfontcombobox.cpp index d601f81..b976b94 100644 --- a/src/gui/widgets/qfontcombobox.cpp +++ b/src/gui/widgets/qfontcombobox.cpp @@ -269,9 +269,8 @@ void QFontComboBoxPrivate::_q_updateModel() void QFontComboBoxPrivate::_q_currentChanged(const QString &text) { Q_Q(QFontComboBox); - QFont newFont(text); - if (currentFont.family() != newFont.family()) { - currentFont = newFont; + if (currentFont.family() != text) { + currentFont.setFamily(text); emit q->currentFontChanged(currentFont); } } diff --git a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp index b974ecab..657be06 100644 --- a/tests/auto/qfontcombobox/tst_qfontcombobox.cpp +++ b/tests/auto/qfontcombobox/tst_qfontcombobox.cpp @@ -144,9 +144,11 @@ void tst_QFontComboBox::currentFont() QFont oldCurrentFont = box.currentFont(); box.setCurrentFont(currentFont); - QCOMPARE(box.currentFont(), currentFont); - QString boxFontFamily = QFontInfo(box.currentFont()).family(); QRegExp foundry(" \\[.*\\]"); + if (!box.currentFont().family().contains(foundry)) { + QCOMPARE(box.currentFont(), currentFont); + } + QString boxFontFamily = QFontInfo(box.currentFont()).family(); if (!currentFont.family().contains(foundry)) boxFontFamily.remove(foundry); QCOMPARE(boxFontFamily, currentFont.family()); |