From 6dec40628b48c673bff8d8fb341ddfdae9189f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Martsum?= Date: Sun, 7 Jul 2013 14:59:27 +0200 Subject: [PATCH] QComboBox - optimize (improve stupid code at enter-key) There is no need to do a search for an item if we already have the correct index. Change-Id: Iac0e7df7573b71b82aa491acb8e289fe02fb3285 Reviewed-by: J-P Nurmi --- src/widgets/widgets/qcombobox.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 6103b9b4c2..c59edf295c 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1136,10 +1136,9 @@ Qt::MatchFlags QComboBoxPrivate::matchFlags() const void QComboBoxPrivate::_q_editingFinished() { Q_Q(QComboBox); - if (lineEdit && !lineEdit->text().isEmpty()) { - //here we just check if the current item was entered + if (lineEdit && !lineEdit->text().isEmpty() && itemText(currentIndex) != lineEdit->text()) { const int index = q_func()->findText(lineEdit->text(), matchFlags()); - if (index != -1 && itemText(currentIndex) != lineEdit->text()) { + if (index != -1) { q->setCurrentIndex(index); emitActivated(currentIndex); }