[qet] [2815] bug fix: segfault when load project with folio report linked but without the same potential text

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


Revision: 2815
Author:   blacksun
Date:     2014-02-06 22:35:13 +0100 (Thu, 06 Feb 2014)
Log Message:
-----------
bug fix: segfault when load project with folio report linked but without the same potential text
(Assert QList(), in conductor.cpp)

Modified Paths:
--------------
    trunk/sources/conductorautonumerotation.cpp
    trunk/sources/conductorautonumerotationwidget.cpp
    trunk/sources/conductorautonumerotationwidget.h
    trunk/sources/diagramcommands.cpp
    trunk/sources/diagramcommands.h
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetgraphicsitem/reportelement.cpp

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2014-02-06 16:43:55 UTC (rev 2814)
+++ trunk/sources/conductorautonumerotation.cpp	2014-02-06 21:35:13 UTC (rev 2815)
@@ -96,10 +96,10 @@
 
 	//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 @@
 	}
 	//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();

Modified: trunk/sources/conductorautonumerotationwidget.cpp
===================================================================
--- trunk/sources/conductorautonumerotationwidget.cpp	2014-02-06 16:43:55 UTC (rev 2814)
+++ trunk/sources/conductorautonumerotationwidget.cpp	2014-02-06 21:35:13 UTC (rev 2815)
@@ -20,11 +20,9 @@
 /**
  * constructor
  */
-ConductorAutoNumerotationWidget::ConductorAutoNumerotationWidget(Conductor *c, QSet<Conductor *> cl, QWidget *parent) :
+ConductorAutoNumerotationWidget::ConductorAutoNumerotationWidget(QSet<Conductor *> cl, QWidget *parent) :
 	QDialog (parent),
-	conductor_(c),
-	c_list(cl),
-	diagram_(c -> diagram())
+	c_list(cl)
 {
 #ifdef Q_WS_MAC
 	setWindowFlags(Qt::Sheet);

Modified: trunk/sources/conductorautonumerotationwidget.h
===================================================================
--- trunk/sources/conductorautonumerotationwidget.h	2014-02-06 16:43:55 UTC (rev 2814)
+++ trunk/sources/conductorautonumerotationwidget.h	2014-02-06 21:35:13 UTC (rev 2815)
@@ -2,7 +2,6 @@
 #define CONDUCTORAUTONUMEROTATIONWIDGET_H
 
 #include <QtGui>
-#include <QList>
 #include <QSet>
 #include <QMultiMap>
 #include <QString>
@@ -13,7 +12,7 @@
 {
 	Q_OBJECT
 	public:
-	explicit ConductorAutoNumerotationWidget(Conductor *, QSet <Conductor *>, QWidget *parent = 0);
+	explicit ConductorAutoNumerotationWidget(QSet <Conductor *>, QWidget *parent = 0);
 	QMultiMap <int, QString> conductorsTextToMap (QSet <Conductor *>);
 	
 	public slots:
@@ -29,10 +28,7 @@
 	QVBoxLayout* buildRadioList();
 
 	//attributes
-	Conductor *conductor_;
 	QSet<Conductor *> c_list; //liste des conducteurs au même potentiel
-	Diagram *diagram_;
-	QList <QRadioButton *> *radio_List;
 	QLineEdit *text_field;
 	QString text_;
 	QSignalMapper *sm_;

Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp	2014-02-06 16:43:55 UTC (rev 2814)
+++ trunk/sources/diagramcommands.cpp	2014-02-06 21:35:13 UTC (rev 2815)
@@ -26,6 +26,7 @@
 #include "diagram.h"
 #include "qetgraphicsitem/diagramtextitem.h"
 #include "qetgraphicsitem/diagramimageitem.h"
+#include "conductorautonumerotation.h"
 
 /**
 	Constructeur
@@ -1153,7 +1154,8 @@
 	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::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;
+	}
 }
 
 /**

Modified: trunk/sources/diagramcommands.h
===================================================================
--- trunk/sources/diagramcommands.h	2014-02-06 16:43:55 UTC (rev 2814)
+++ trunk/sources/diagramcommands.h	2014-02-06 21:35:13 UTC (rev 2815)
@@ -600,6 +600,7 @@
 	//attributes
 	Diagram *diagram_;
 	Element *elmt_1, *elmt_2, *previous_report;
+	bool first_redo;
 };
 
 class unlinkElementsCommand : public QUndoCommand {

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2014-02-06 16:43:55 UTC (rev 2814)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2014-02-06 21:35:13 UTC (rev 2815)
@@ -1395,6 +1395,7 @@
  * @return l'editeur de schemas parent ou 0
  */
 QETDiagramEditor* Conductor::diagramEditor() const {
+	if (diagram()->views().isEmpty()) return 0;
 	QWidget *w = const_cast<QGraphicsView *>(diagram() -> views().at(0));
 	while (w -> parentWidget() && !w -> isWindow()) {
 		w = w -> parentWidget();

Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp	2014-02-06 16:43:55 UTC (rev 2814)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp	2014-02-06 21:35:13 UTC (rev 2815)
@@ -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 @@
 		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 @@
 		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());
-		}
 	}
 }
 


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