diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-08-25 16:24:44 +0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-09-22 00:01:43 +0000 |
commit | d29f0bc65c1817bb73153cd546d7ab76e0768be0 (patch) | |
tree | a3f02964f25e67356ba28510e6ad840eba4b781c /src/widgets/widgets/qcombobox.cpp | |
parent | c84b4ff4958bf3be513b3108d5a07d6565f95a98 (diff) |
Avoid calling QCompleter::popup() internally
QCompleter::popup() is used to lazily create the popup itself.
However, we oftentimes call this function only to check if the
popup is visible.
Change-Id: I55531e1e6810c02a44f5f65124cf641b1a89de69
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index b6bb31c391..54d33a7eea 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -71,6 +71,7 @@ #include <private/qabstractitemmodel_p.h> #include <private/qabstractscrollarea_p.h> #include <private/qlineedit_p.h> +#include <private/qcompleter_p.h> #include <qdebug.h> #if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(effetcts) && QT_CONFIG(style_mac) #include <private/qcore_mac_p.h> @@ -3140,13 +3141,13 @@ void QComboBox::keyPressEvent(QKeyEvent *e) Q_D(QComboBox); #if QT_CONFIG(completer) - if (d->lineEdit - && d->lineEdit->completer() - && d->lineEdit->completer()->popup() - && d->lineEdit->completer()->popup()->isVisible()) { - // provide same autocompletion support as line edit - d->lineEdit->event(e); - return; + if (const auto *cmpltr = completer()) { + const auto *popup = QCompleterPrivate::get(cmpltr)->popup; + if (popup && popup->isVisible()) { + // provide same autocompletion support as line edit + d->lineEdit->event(e); + return; + } } #endif |