From 5ec8a27470d4004a60a2d9fc6bd757bbebae1fd7 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 1 Apr 2009 12:21:50 +0200 Subject: QComboBox with Qt::NoFocus triggers a crash. The showPopup() from a combobox triggers a crash. This happens only for a combobox which dosen't accept focus and it has been recreated. This is due to some invalid widget pointer stored in the input context. Task-number: 249576 Reviewed-by: ddenis --- src/gui/kernel/qapplication.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index c4224ed..09f0f91 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2055,9 +2055,13 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) QWidget *prev = focus_widget; focus_widget = focus; - if (prev && reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason && - prev->testAttribute(Qt::WA_InputMethodEnabled)) { - QInputContext *qic = prev->inputContext(); + if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason + && prev->testAttribute(Qt::WA_InputMethodEnabled)) + // Do reset the input context, in case the new focus widget won't accept keyboard input + // or it is not created fully yet. + || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled) + || !focus_widget->testAttribute(Qt::WA_WState_Created))))) { + QInputContext *qic = prev->inputContext(); if(qic) { qic->reset(); qic->setFocusWidget(0); -- cgit v0.12