diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 9664004455..394a968aad 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -840,8 +840,8 @@ void QCompleterPrivate::setCurrentIndex(QModelIndex index, bool select) void QCompleterPrivate::_q_completionSelected(const QItemSelection& selection) { QModelIndex index; - if (!selection.indexes().isEmpty()) - index = selection.indexes().first(); + if (const auto indexes = selection.indexes(); !indexes.isEmpty()) + index = indexes.first(); _q_complete(index, true); }