From 02395c69378bcea08465154a779d2f104a7702c5 Mon Sep 17 00:00:00 2001
From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com>
Date: Thu, 28 Jun 2012 16:03:22 -0400
Subject: [PATCH] [ #13035 ] Fix crash when hangging up coferences with ourself

---
 kde/src/CallView.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kde/src/CallView.cpp b/kde/src/CallView.cpp
index 7fdf6151a2..ad0ca32bc4 100644
--- a/kde/src/CallView.cpp
+++ b/kde/src/CallView.cpp
@@ -588,9 +588,11 @@ void CallView::destroyCall(Call* toDestroy)
    else if (SFLPhone::model()->getIndex(toDestroy)->parent()) {
       QTreeWidgetItem* callIndex = SFLPhone::model()->getIndex(toDestroy);
       QTreeWidgetItem* parent = callIndex->parent();
-      parent->removeChild(callIndex);
-      if (dynamic_cast<QTreeWidgetItem*>(parent) && parent->childCount() == 0) /*This should never happen, but it does*/
-         takeTopLevelItem(indexOfTopLevelItem(parent));
+      if (indexOfTopLevelItem(parent) != -1) {
+         parent->removeChild(callIndex);
+         if (dynamic_cast<QTreeWidgetItem*>(parent) && parent->childCount() == 0) /*This should never happen, but it does*/
+            takeTopLevelItem(indexOfTopLevelItem(parent));
+      }
    }
    else
       kDebug() << "Call not found";
-- 
GitLab