]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Do not crash when finishing inline renaming in unusual ways
authorFrank Reininghaus <frank78ac@googlemail.com>
Fri, 24 Aug 2012 21:21:31 +0000 (23:21 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Fri, 24 Aug 2012 21:29:17 +0000 (23:29 +0200)
The crash was caused by a null pointer dereference when, e.g.,
minimizing Dolphin. The root cause was that
KStandardItemListWidget::closeRoleEditor() was called twice: once when
the role editor loses focus, and once again when the window is resized.
After m_roleEditor was set to 0, the second call dereferenced this null
pointer. I think the best solution is to disconnect from the role
editor's signals when the editor is not needed any more by the
KStandardItemListWidget.

CCBUG: 304524
(cherry picked from commit a9c2bdc3b53955693e716bbab58c318fe25bdc9b)

src/kitemviews/kstandarditemlistwidget.cpp

index 3a76f14a2702fb63cdae7771dc6c62a6d734864e..7ae7e2efcffc2f68c72a05cdbc3b29abc4c3aff4 100644 (file)
@@ -594,6 +594,11 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
    if (current.isEmpty() || !parent || current != "text") {
         if (m_roleEditor) {
             emit roleEditingCanceled(index(), current, data().value(current));
+
+            disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
+                       this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
+            disconnect(m_roleEditor, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
+                       this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
             m_roleEditor->deleteLater();
             m_roleEditor = 0;
         }
@@ -1253,6 +1258,11 @@ void KStandardItemListWidget::closeRoleEditor()
         // to transfer the keyboard focus back to the KItemListContainer.
         scene()->views()[0]->parentWidget()->setFocus();
     }
+
+    disconnect(m_roleEditor, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
+               this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
+    disconnect(m_roleEditor, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
+               this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
     m_roleEditor->deleteLater();
     m_roleEditor = 0;
 }