From c7d70d35a511f747a132f69b4ada9223d7971337 Mon Sep 17 00:00:00 2001 From: blacksun Date: Wed, 16 Oct 2013 19:10:11 +0000 Subject: [PATCH] fix memory leak (pointer not deleted) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2574 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/conductor.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sources/conductor.cpp b/sources/conductor.cpp index ead9db9a8..22cb53608 100644 --- a/sources/conductor.cpp +++ b/sources/conductor.cpp @@ -1322,13 +1322,16 @@ QSet Conductor::relatedConductors() const { * le meme potentiel electrique a l'exception de lui même */ QSet Conductor::relatedPotentialConductors(QList *t_list) { - if (t_list == 0) + bool declar_t_list = false; + if (t_list == 0) { + declar_t_list = true; t_list = new QList ; + } QSet 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 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 @@ QSet Conductor::relatedPotentialConductors(QList *t_li 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 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 @@ QSet Conductor::relatedPotentialConductors(QList *t_li other_conductors += other_conductors_list_t2.toSet(); } other_conductors.remove(const_cast(this)); + + if (declar_t_list) delete t_list; return(other_conductors); }