[qet] [1347] Fixed a segfault that could occur when removing a diagram from a project.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 1347
Author:   xavier
Date:     2011-10-01 21:22:30 +0200 (Sat, 01 Oct 2011)
Log Message:
-----------
Fixed a segfault that could occur when removing a diagram from a project.

Modified Paths:
--------------
    branches/0.3/sources/elementspanel.cpp

Modified: branches/0.3/sources/elementspanel.cpp
===================================================================
--- branches/0.3/sources/elementspanel.cpp	2011-10-01 19:17:11 UTC (rev 1346)
+++ branches/0.3/sources/elementspanel.cpp	2011-10-01 19:22:30 UTC (rev 1347)
@@ -307,7 +307,8 @@
 	@return true si un schema est selectionne, false sinon
 */
 bool ElementsPanel::selectedItemIsADiagram() const {
-	return(diagrams_.contains(currentItem()));
+	QTreeWidgetItem *current = currentItem();
+	return(diagrams_.contains(current));
 }
 
 /**
@@ -890,11 +891,6 @@
 void ElementsPanel::deleteItem(QTreeWidgetItem *removed_item) {
 	if (!removed_item) return;
 	
-	// supprime les eventuels enfants de l'item
-	foreach(QTreeWidgetItem *child_item, removed_item -> takeChildren()) {
-		deleteItem(child_item);
-	}
-	
 	if (locations_.contains(removed_item)) {
 		locations_.remove(removed_item);
 	} else if (diagrams_.contains(removed_item)) {
@@ -904,6 +900,12 @@
 	} else if (title_blocks_directories_.contains(removed_item)) {
 		title_blocks_directories_.remove(removed_item);
 	}
+	
+	// supprime les eventuels enfants de l'item
+	foreach(QTreeWidgetItem *child_item, removed_item -> takeChildren()) {
+		deleteItem(child_item);
+	}
+	
 	delete removed_item;
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/