From 8ed2b25f87bc632d0e7d375c3506fab1c59ca1a2 Mon Sep 17 00:00:00 2001
From: Sami Merila <sami.merila@nokia.com>
Date: Thu, 9 Sep 2010 14:36:32 +0300
Subject: Editable QComboBox popup immediately closes itself after a click

This is due that timer that blocks for while mouse release events
(blockMouseReleaseTimer) is not started. There is an optimization
in QComboBox that tries to avoid calling d->viewContainer() since
that method creates the viewContainter if it doesn't exist.
Unfortunately this optimization does not take into account if the
container is already created.

In this particular case, viewContainer is already created, but
since QComboBox creates a QLineEdit, it skips the timer start,
which leads to situation where combobox's popup menu receiving
mouse release event and thus closes itself.

As a fix, blockMouseReleaseTimer is started if the viewContainer is
already created.

Task-number: QTBUG-13231
Reviewed-by: axis
---
 src/gui/widgets/qcombobox.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 917a325..96d2acd 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -2849,7 +2849,8 @@ void QComboBox::mousePressEvent(QMouseEvent *e)
         if (sc == QStyle::SC_ComboBoxArrow)
             d->updateArrow(QStyle::State_Sunken);
 #ifdef QT_KEYPAD_NAVIGATION
-        if (!d->lineEdit) {
+        //if the container already exists, then d->viewContainer() is safe to call
+        if (d->container) {
 #endif
             // We've restricted the next couple of lines, because by not calling
             // viewContainer(), we avoid creating the QComboBoxPrivateContainer.
-- 
cgit v0.12