From e1c2c4ce90c0d9b11b4df183241e4699c4022e6c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com> Date: Fri, 16 Dec 2011 17:50:52 -0500 Subject: [PATCH] [ #7929 ] Add some client side work around until it is fixed --- kde/src/CallView.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/kde/src/CallView.cpp b/kde/src/CallView.cpp index 7211f1fbf7..7fe031b493 100644 --- a/kde/src/CallView.cpp +++ b/kde/src/CallView.cpp @@ -466,9 +466,12 @@ Call* CallView::getCurrentItem() ///Remove a TreeView item and delete it bool CallView::removeItem(Call* item) { - if (indexOfTopLevelItem(SFLPhone::model()->getIndex(item)) != -1) {//TODO To remove once safe - removeItemWidget(SFLPhone::model()->getIndex(item),0); - return true; + if (indexOfTopLevelItem(SFLPhone::model()->getIndex(item)) != -1) { + QTreeWidgetItem* parent = itemAt(indexOfTopLevelItem(SFLPhone::model()->getIndex(item)),0); + removeItemWidget(SFLPhone::model()->getIndex(item),0); + if (parent->childCount() == 0) //TODO this have to be done in the daemon, not here, but oops still happen too often to ignore + removeItemWidget(parent,0); + return true; } else return false; @@ -550,8 +553,16 @@ void CallView::destroyCall(Call* toDestroy) kDebug() << "Call not found"; else if (indexOfTopLevelItem(SFLPhone::model()->getIndex(toDestroy)) != -1) takeTopLevelItem(indexOfTopLevelItem(SFLPhone::model()->getIndex(toDestroy))); - else if (SFLPhone::model()->getIndex(toDestroy)->parent()) //May crash here + else if (SFLPhone::model()->getIndex(toDestroy)->parent()) { + QTreeWidgetItem* parent = SFLPhone::model()->getIndex(toDestroy)->parent(); SFLPhone::model()->getIndex(toDestroy)->parent()->removeChild(SFLPhone::model()->getIndex(toDestroy)); + if (parent->childCount() == 0) /*This should never happen, but it does*/ + takeTopLevelItem(indexOfTopLevelItem(parent)); + else if (parent->childCount() == 1) { + addTopLevelItem(extractItem(parent->child(0))); + takeTopLevelItem(indexOfTopLevelItem(parent)); + } //TODO make sure it just never happen and remove this logic code + } else kDebug() << "Call not found"; } -- GitLab