From 801a2d298f103d4b58bbebc53d299d026f33e4ce Mon Sep 17 00:00:00 2001 From: blacksun Date: Thu, 6 Feb 2014 21:35:13 +0000 Subject: [PATCH] bug fix: segfault when load project with folio report linked but without the same potential text (Assert QList(), in conductor.cpp) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2815 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/conductorautonumerotation.cpp | 8 ++++---- sources/conductorautonumerotationwidget.cpp | 6 ++---- sources/conductorautonumerotationwidget.h | 6 +----- sources/diagramcommands.cpp | 11 ++++++++++- sources/diagramcommands.h | 1 + sources/qetgraphicsitem/conductor.cpp | 1 + sources/qetgraphicsitem/reportelement.cpp | 7 +------ 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/sources/conductorautonumerotation.cpp b/sources/conductorautonumerotation.cpp index 8901cb792..0c087ad67 100644 --- a/sources/conductorautonumerotation.cpp +++ b/sources/conductorautonumerotation.cpp @@ -96,10 +96,10 @@ void ConductorAutoNumerotation::checkPotential(Conductor *conductor) { //check text list, isn't same in potential, ask user what to do if (!eachIsEqual(strl)) { - ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor, c_list, conductor -> diagramEditor()); + ConductorAutoNumerotationWidget canw(c_list, conductor -> diagramEditor()); ConductorAutoNumerotation can(conductor); - connect(canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString))); - canw -> exec(); + connect(&canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString))); + canw.exec(); } } @@ -168,7 +168,7 @@ void ConductorAutoNumerotation::numeratePotential() { } //the texts isn't identicals else { - ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor_, conductor_list, conductor_ -> diagramEditor()); + ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor_list, conductor_ -> diagramEditor()); connect(canw, SIGNAL(textIsSelected(QString)), this, SLOT(applyText(QString))); canw -> exec(); diff --git a/sources/conductorautonumerotationwidget.cpp b/sources/conductorautonumerotationwidget.cpp index 51e210536..1931f4d7c 100644 --- a/sources/conductorautonumerotationwidget.cpp +++ b/sources/conductorautonumerotationwidget.cpp @@ -20,11 +20,9 @@ /** * constructor */ -ConductorAutoNumerotationWidget::ConductorAutoNumerotationWidget(Conductor *c, QSet cl, QWidget *parent) : +ConductorAutoNumerotationWidget::ConductorAutoNumerotationWidget(QSet cl, QWidget *parent) : QDialog (parent), - conductor_(c), - c_list(cl), - diagram_(c -> diagram()) + c_list(cl) { #ifdef Q_WS_MAC setWindowFlags(Qt::Sheet); diff --git a/sources/conductorautonumerotationwidget.h b/sources/conductorautonumerotationwidget.h index 675dee5ca..21f48c031 100644 --- a/sources/conductorautonumerotationwidget.h +++ b/sources/conductorautonumerotationwidget.h @@ -2,7 +2,6 @@ #define CONDUCTORAUTONUMEROTATIONWIDGET_H #include -#include #include #include #include @@ -13,7 +12,7 @@ class ConductorAutoNumerotationWidget : public QDialog { Q_OBJECT public: - explicit ConductorAutoNumerotationWidget(Conductor *, QSet , QWidget *parent = 0); + explicit ConductorAutoNumerotationWidget(QSet , QWidget *parent = 0); QMultiMap conductorsTextToMap (QSet ); public slots: @@ -29,10 +28,7 @@ class ConductorAutoNumerotationWidget : public QDialog QVBoxLayout* buildRadioList(); //attributes - Conductor *conductor_; QSet c_list; //liste des conducteurs au même potentiel - Diagram *diagram_; - QList *radio_List; QLineEdit *text_field; QString text_; QSignalMapper *sm_; diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index 780d81b3b..bf14d009c 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -26,6 +26,7 @@ #include "diagram.h" #include "qetgraphicsitem/diagramtextitem.h" #include "qetgraphicsitem/diagramimageitem.h" +#include "conductorautonumerotation.h" /** Constructeur @@ -1153,7 +1154,8 @@ LinkElementsCommand::LinkElementsCommand(Element *elmt1, Element *elmt2, QUndoCo diagram_(elmt1->diagram()), elmt_1(elmt1), elmt_2(elmt2), - previous_report(0) + previous_report(0), + first_redo(true) { if (elmt1->linkType() & Element::AllReport && elmt2->linkType() & Element::AllReport) { @@ -1189,6 +1191,13 @@ void LinkElementsCommand::undo() { void LinkElementsCommand::redo() { diagram_->showMe(); elmt_1->linkToElement(elmt_2); + //Check if text of this potential is identical. + if (first_redo) { + if(elmt_1->conductors().count() && elmt_2->conductors().count()) { + ConductorAutoNumerotation::checkPotential(elmt_1->conductors().first()); + } + first_redo = false; + } } /** diff --git a/sources/diagramcommands.h b/sources/diagramcommands.h index 19018767d..b4291655f 100644 --- a/sources/diagramcommands.h +++ b/sources/diagramcommands.h @@ -600,6 +600,7 @@ class LinkElementsCommand : public QUndoCommand { //attributes Diagram *diagram_; Element *elmt_1, *elmt_2, *previous_report; + bool first_redo; }; class unlinkElementsCommand : public QUndoCommand { diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 3a3b10e5e..d87d1b36f 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1395,6 +1395,7 @@ Terminal * Conductor::relatedPotentialTerminal (Terminal *t) { * @return l'editeur de schemas parent ou 0 */ QETDiagramEditor* Conductor::diagramEditor() const { + if (diagram()->views().isEmpty()) return 0; QWidget *w = const_cast(diagram() -> views().at(0)); while (w -> parentWidget() && !w -> isWindow()) { w = w -> parentWidget(); diff --git a/sources/qetgraphicsitem/reportelement.cpp b/sources/qetgraphicsitem/reportelement.cpp index 697acb617..66074c90c 100644 --- a/sources/qetgraphicsitem/reportelement.cpp +++ b/sources/qetgraphicsitem/reportelement.cpp @@ -19,7 +19,6 @@ #include "elementtextitem.h" #include "diagramposition.h" #include "qetproject.h" -#include "conductorautonumerotation.h" ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) : CustomElement(location, qgi, s, state) @@ -50,7 +49,7 @@ void ReportElement::linkToElement(Element * elmt) { if (connected_elements.first() == elmt) i = false; } - //ensure elmt is a inverse report of this element + //ensure elmt is an inverse report of this element if ((elmt->linkType() == inverse_report) && i) { unlinkAllElements(); connected_elements << elmt; @@ -58,10 +57,6 @@ void ReportElement::linkToElement(Element * elmt) { connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); updateLabel(); elmt->linkToElement(this); - //Check if text of this potential is identical. - if (conductors().count() && elmt->conductors().count()) { - ConductorAutoNumerotation::checkPotential(conductors().first()); - } } }