diff options
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 4840b75c1b..aab28bf18a 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -546,7 +546,8 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView) disconnect(view, SIGNAL(destroyed()), this, SLOT(viewDestroyed())); - delete view; + if (isAncestorOf(view)) + delete view; view = 0; } @@ -653,8 +654,9 @@ void QComboBoxPrivateContainer::changeEvent(QEvent *e) bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) { switch (e->type()) { - case QEvent::ShortcutOverride: - switch (static_cast<QKeyEvent*>(e)->key()) { + case QEvent::ShortcutOverride: { + QKeyEvent *keyEvent = static_cast<QKeyEvent*>(e); + switch (keyEvent->key()) { case Qt::Key_Enter: case Qt::Key_Return: #ifdef QT_KEYPAD_NAVIGATION @@ -666,17 +668,21 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) } return true; case Qt::Key_Down: - if (!(static_cast<QKeyEvent*>(e)->modifiers() & Qt::AltModifier)) + if (!(keyEvent->modifiers() & Qt::AltModifier)) break; // fall through case Qt::Key_F4: - case Qt::Key_Escape: combo->hidePopup(); return true; default: + if (keyEvent->matches(QKeySequence::Cancel)) { + combo->hidePopup(); + return true; + } break; } - break; + break; + } case QEvent::MouseMove: if (isVisible()) { QMouseEvent *m = static_cast<QMouseEvent *>(e); @@ -2268,6 +2274,7 @@ void QComboBox::insertItems(int index, const QStringList &list) // construct a QStandardItem, reducing the number of expensive signals from the model if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(d->model)) { QList<QStandardItem *> items; + items.reserve(insertCount); QStandardItem *hiddenRoot = m->invisibleRootItem(); for (int i = 0; i < insertCount; ++i) items.append(new QStandardItem(list.at(i))); @@ -3028,9 +3035,6 @@ void QComboBox::mousePressEvent(QMouseEvent *e) d->showPopupFromMouseEvent(e); } -/*! - \reimp -*/ void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e) { Q_Q(QComboBox); |