diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-03-03 17:00:18 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-04 10:31:34 +0100 |
commit | 204eaf0c491a29681dad87751f93e3079e08f0b4 (patch) | |
tree | 4bdf2b544f9e72489aa0ce2a74c3c91cfbdb861d | |
parent | dddf2c7d66ed7169ab03e0469b6ffec400e00050 (diff) | |
download | qtwebkit-204eaf0c491a29681dad87751f93e3079e08f0b4.tar.gz |
Avoid deleting QtWebComboBox it's own nested QEventLoop
A race condition meant that sometimes a QtWebComboBox would be deleted
in an eventloop run while hiding itself. This patch adds a flags
and delays scheduling a deletion until after the nested eventloop.
Task-number: QTBUG-29844
Change-Id: Ia5e03954756afa29c0be0a2d7f49ae8d1dbba250
Reviewed-by: Michael Bruning <michael.bruning@digia.com>
-rw-r--r-- | Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp | 2 | ||||
-rw-r--r-- | Source/WebKit/qt/WidgetSupport/QtWebComboBox.cpp | 21 | ||||
-rw-r--r-- | Source/WebKit/qt/WidgetSupport/QtWebComboBox.h | 7 |
3 files changed, 28 insertions, 2 deletions
diff --git a/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp b/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp index 5bf90d800..61ddacaa8 100644 --- a/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp +++ b/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp @@ -128,7 +128,7 @@ void QtFallbackWebPopup::deleteComboBox() { if (!m_combo) return; - m_combo->deleteLater(); + m_combo->deleteComboBox(); m_combo = 0; } diff --git a/Source/WebKit/qt/WidgetSupport/QtWebComboBox.cpp b/Source/WebKit/qt/WidgetSupport/QtWebComboBox.cpp index 2c22cd476..4cfa366dc 100644 --- a/Source/WebKit/qt/WidgetSupport/QtWebComboBox.cpp +++ b/Source/WebKit/qt/WidgetSupport/QtWebComboBox.cpp @@ -31,7 +31,7 @@ namespace WebCore { QtWebComboBox::QtWebComboBox() - : QComboBox() + : QComboBox(), m_hiding(false), m_deleteAfterHiding(false) { // Install an event filter on the view inside the combo box popup to make sure we know // when the popup got closed. E.g. QComboBox::hidePopup() won't be called when the popup @@ -53,6 +53,25 @@ bool QtWebComboBox::eventFilter(QObject* watched, QEvent* event) return false; } +void QtWebComboBox::hidePopup() +{ + m_hiding = true; + // QComboBox::hidePopup() runs an eventloop, we need to make sure we do not delete ourselves in that loop. + QComboBox::hidePopup(); + m_hiding = false; + if (m_deleteAfterHiding) + deleteLater(); +} + + +void QtWebComboBox::deleteComboBox() +{ + if (!m_hiding) + deleteLater(); + else + m_deleteAfterHiding = true; } +} // namespace + #endif // QT_NO_COMBOBOX diff --git a/Source/WebKit/qt/WidgetSupport/QtWebComboBox.h b/Source/WebKit/qt/WidgetSupport/QtWebComboBox.h index e32427edf..90b617b3d 100644 --- a/Source/WebKit/qt/WidgetSupport/QtWebComboBox.h +++ b/Source/WebKit/qt/WidgetSupport/QtWebComboBox.h @@ -36,8 +36,15 @@ public: void showPopupAtCursorPosition(); virtual bool eventFilter(QObject* watched, QEvent*); + virtual void hidePopup() OVERRIDE; + void deleteComboBox(); + Q_SIGNALS: void didHide(); + +private: + bool m_hiding; + bool m_deleteAfterHiding; }; } |