[qet] [2574] fix memory leak (pointer not deleted)

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


Revision: 2574
Author:   blacksun
Date:     2013-10-16 21:10:11 +0200 (Wed, 16 Oct 2013)
Log Message:
-----------
fix memory leak (pointer not deleted)

Modified Paths:
--------------
    trunk/sources/conductor.cpp

Modified: trunk/sources/conductor.cpp
===================================================================
--- trunk/sources/conductor.cpp	2013-10-16 18:47:14 UTC (rev 2573)
+++ trunk/sources/conductor.cpp	2013-10-16 19:10:11 UTC (rev 2574)
@@ -1322,13 +1322,16 @@
  *  le meme potentiel electrique a l'exception de lui même
  */
 QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_list) {
-	if (t_list == 0)
+	bool declar_t_list = false;
+	if (t_list == 0) {
+		declar_t_list = true;
 		t_list = new QList <Terminal *>;
+	}
 
 	QSet <Conductor *> other_conductors;
 	//renvoie tous les conducteurs du terminal 1
-	if (t_list->contains(terminal1) == false) {
-		t_list->append(terminal1);
+	if (!t_list -> contains(terminal1)) {
+		t_list -> append(terminal1);
 		QList <Conductor *> other_conductors_list_t1 = terminal1 -> conductors();
 		other_conductors_list_t1.removeAll(this);
 		//recherche les conducteurs connecté au conducteur déjà trouvé
@@ -1338,8 +1341,8 @@
 		other_conductors += other_conductors_list_t1.toSet();
 	}
 	//renvoie tous les conducteurs du terminal 2
-	if (t_list->contains(terminal2) == false) {
-		t_list->append(terminal2);
+	if (!t_list -> contains(terminal2)) {
+		t_list -> append(terminal2);
 		QList <Conductor *> other_conductors_list_t2 = terminal2 -> conductors();
 		other_conductors_list_t2.removeAll(this);
 		//recherche les conducteurs connecté au conducteur déjà trouvé
@@ -1349,6 +1352,8 @@
 		other_conductors += other_conductors_list_t2.toSet();
 	}
 	other_conductors.remove(const_cast<Conductor *>(this));
+
+	if (declar_t_list) delete t_list;
 	return(other_conductors);
 }
 


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