[qet] [3015] Bug fix: qet crash when close a diagram with a cross ref item.

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


Revision: 3015
Author:   blacksun
Date:     2014-04-21 01:37:03 +0200 (Mon, 21 Apr 2014)
Log Message:
-----------
Bug fix: qet crash when close a diagram with a cross ref item.

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/qetgraphicsitem/crossrefitem.h

Added Paths:
-----------
    trunk/dev_doc/
    trunk/dev_doc/enum_type_of_QGraphicsItem

Added: trunk/dev_doc/enum_type_of_QGraphicsItem
===================================================================
--- trunk/dev_doc/enum_type_of_QGraphicsItem	                        (rev 0)
+++ trunk/dev_doc/enum_type_of_QGraphicsItem	2014-04-20 23:37:03 UTC (rev 3015)
@@ -0,0 +1,12 @@
+		Type = UserType + ???
+Element + 1000
+Conductor + 1001
+Terminal + 1002
+ElementTextItem + 1003
+DiagramTextItem + 1004
+IndependentTextItem + 1005
+ConductorTextItem + 1006
+DiagramImageItem + 1007
+QetShapItem + 1008
+crossRefItem + 1009
+ElementPrimitiveDecorator + 2200

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2014-04-20 18:53:10 UTC (rev 3014)
+++ trunk/sources/diagram.cpp	2014-04-20 23:37:03 UTC (rev 3015)
@@ -33,6 +33,7 @@
 #include "qetapp.h"
 #include "qetgraphicsitem/diagramimageitem.h"
 #include "qetgraphicsitem/qetshapeitem.h"
+#include "qetgraphicsitem/crossrefitem.h"
 
 const int   Diagram::xGrid  = 10;
 const int   Diagram::yGrid  = 10;
@@ -80,32 +81,32 @@
 }
 
 /**
-	Destructeur
-*/
+ * @brief Diagram::~Diagram
+ * Destructor
+ */
 Diagram::~Diagram() {
 	// clear undo stack to prevent errors, because contains pointers to this diagram and is elements.
 	undoStack().clear();
-	// suppression du QGIManager - tous les elements qu'il connait sont supprimes
+	//delete of QGIManager, every elements he knows are removed
 	delete qgi_manager_;
 	// remove of conductor setter
 	delete conductor_setter_;
 	
-	// suppression des objets gerant les deplacements
+	// delete of object for manage movement
 	delete elements_mover_;
 	delete element_texts_mover_;
 	
-	// recense les items supprimables
+	// list removable items
 	QList<QGraphicsItem *> deletable_items;
 	foreach(QGraphicsItem *qgi, items()) {
 		if (qgi -> parentItem()) continue;
 		if (qgraphicsitem_cast<Conductor *>(qgi)) continue;
+		else if (qgraphicsitem_cast<CrossRefItem *>(qgi)) continue;
+
 		deletable_items << qgi;
 	}
-	
-	// suppression des items supprimables
-	foreach(QGraphicsItem *qgi_d, deletable_items) {
-		delete qgi_d;
-	}
+
+	qDeleteAll (deletable_items);
 }
 
 /**

Modified: trunk/sources/qetgraphicsitem/crossrefitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.h	2014-04-20 18:53:10 UTC (rev 3014)
+++ trunk/sources/qetgraphicsitem/crossrefitem.h	2014-04-20 23:37:03 UTC (rev 3015)
@@ -39,6 +39,9 @@
 	explicit CrossRefItem(Element *elmt, QGraphicsItem *parent = 0);
 	~CrossRefItem();
 
+	enum { Type = UserType + 1009 };
+	virtual int type() const { return Type; }
+
 	QRectF boundingRect() const;
 	virtual QPainterPath shape() const;
 


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