[kde-doc-english] [trojita] src/Gui: GUI: Fix segfault in address completion popup

Jan Kundrát jkt at kde.org
Fri Jul 24 07:15:08 UTC 2015


Git commit de4f3ec63b4f0ac5a5a29576bb8de7e08cdab541 by Jan Kundrát.
Committed on 23/07/2015 at 22:35.
Pushed by gerrit into branch 'master'.

GUI: Fix segfault in address completion popup

This eventFilter was getting called even if m_completionReceiver was a
nullptr. Looking at the code, it seems that we were doing this pointer
manipulation in an unsafe way; we were setting m_completionReceiver to
nullptr explicitly but we were not disabling the eventFilter.

My current understanding (which might be wrong) is that this is caused
by the asynchronous nature of input event handling where Qt still sends
us key events even though our code has already closed the
m_completionPopup.

Thanks to Thomas Lübking for feedback and additional information here.

Change-Id: Ia0836dabb03868f8e575039053a12d32ff01b8db

M  +4    -0    src/Gui/ComposeWidget.cpp

http://commits.kde.org/trojita/de4f3ec63b4f0ac5a5a29576bb8de7e08cdab541

diff --git a/src/Gui/ComposeWidget.cpp b/src/Gui/ComposeWidget.cpp
index 6f3dd1c..7e6d9fa 100644
--- a/src/Gui/ComposeWidget.cpp
+++ b/src/Gui/ComposeWidget.cpp
@@ -1201,11 +1201,15 @@ void ComposeWidget::completeRecipient(QAction *act)
 bool ComposeWidget::eventFilter(QObject *o, QEvent *e)
 {
     if (o == m_completionPopup) {
+        if (!m_completionPopup->isVisible())
+            return false;
+
         if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
             QKeyEvent *ke = static_cast<QKeyEvent*>(e);
             if (!(  ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down || // Navigation
                     ke->key() == Qt::Key_Escape || // "escape"
                     ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter)) { // selection
+                Q_ASSERT(m_completionReceiver);
                 QCoreApplication::sendEvent(m_completionReceiver, e);
                 return true;
             }



More information about the kde-doc-english mailing list