mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
fix memory leak (pointer not deleted)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2574 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1322,13 +1322,16 @@ QSet<Conductor *> Conductor::relatedConductors() const {
|
||||
* 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 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *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 <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 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_li
|
||||
other_conductors += other_conductors_list_t2.toSet();
|
||||
}
|
||||
other_conductors.remove(const_cast<Conductor *>(this));
|
||||
|
||||
if (declar_t_list) delete t_list;
|
||||
return(other_conductors);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user