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
This commit is contained in:
blacksun
2014-02-06 21:35:13 +00:00
parent 0e46586892
commit 801a2d298f
7 changed files with 20 additions and 20 deletions

View File

@@ -96,10 +96,10 @@ void ConductorAutoNumerotation::checkPotential(Conductor *conductor) {
//check text list, isn't same in potential, ask user what to do //check text list, isn't same in potential, ask user what to do
if (!eachIsEqual(strl)) { if (!eachIsEqual(strl)) {
ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor, c_list, conductor -> diagramEditor()); ConductorAutoNumerotationWidget canw(c_list, conductor -> diagramEditor());
ConductorAutoNumerotation can(conductor); ConductorAutoNumerotation can(conductor);
connect(canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString))); connect(&canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString)));
canw -> exec(); canw.exec();
} }
} }
@@ -168,7 +168,7 @@ void ConductorAutoNumerotation::numeratePotential() {
} }
//the texts isn't identicals //the texts isn't identicals
else { else {
ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor_, conductor_list, conductor_ -> diagramEditor()); ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor_list, conductor_ -> diagramEditor());
connect(canw, SIGNAL(textIsSelected(QString)), connect(canw, SIGNAL(textIsSelected(QString)),
this, SLOT(applyText(QString))); this, SLOT(applyText(QString)));
canw -> exec(); canw -> exec();

View File

@@ -20,11 +20,9 @@
/** /**
* constructor * constructor
*/ */
ConductorAutoNumerotationWidget::ConductorAutoNumerotationWidget(Conductor *c, QSet<Conductor *> cl, QWidget *parent) : ConductorAutoNumerotationWidget::ConductorAutoNumerotationWidget(QSet<Conductor *> cl, QWidget *parent) :
QDialog (parent), QDialog (parent),
conductor_(c), c_list(cl)
c_list(cl),
diagram_(c -> diagram())
{ {
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
setWindowFlags(Qt::Sheet); setWindowFlags(Qt::Sheet);

View File

@@ -2,7 +2,6 @@
#define CONDUCTORAUTONUMEROTATIONWIDGET_H #define CONDUCTORAUTONUMEROTATIONWIDGET_H
#include <QtGui> #include <QtGui>
#include <QList>
#include <QSet> #include <QSet>
#include <QMultiMap> #include <QMultiMap>
#include <QString> #include <QString>
@@ -13,7 +12,7 @@ class ConductorAutoNumerotationWidget : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ConductorAutoNumerotationWidget(Conductor *, QSet <Conductor *>, QWidget *parent = 0); explicit ConductorAutoNumerotationWidget(QSet <Conductor *>, QWidget *parent = 0);
QMultiMap <int, QString> conductorsTextToMap (QSet <Conductor *>); QMultiMap <int, QString> conductorsTextToMap (QSet <Conductor *>);
public slots: public slots:
@@ -29,10 +28,7 @@ class ConductorAutoNumerotationWidget : public QDialog
QVBoxLayout* buildRadioList(); QVBoxLayout* buildRadioList();
//attributes //attributes
Conductor *conductor_;
QSet<Conductor *> c_list; //liste des conducteurs au même potentiel QSet<Conductor *> c_list; //liste des conducteurs au même potentiel
Diagram *diagram_;
QList <QRadioButton *> *radio_List;
QLineEdit *text_field; QLineEdit *text_field;
QString text_; QString text_;
QSignalMapper *sm_; QSignalMapper *sm_;

View File

@@ -26,6 +26,7 @@
#include "diagram.h" #include "diagram.h"
#include "qetgraphicsitem/diagramtextitem.h" #include "qetgraphicsitem/diagramtextitem.h"
#include "qetgraphicsitem/diagramimageitem.h" #include "qetgraphicsitem/diagramimageitem.h"
#include "conductorautonumerotation.h"
/** /**
Constructeur Constructeur
@@ -1153,7 +1154,8 @@ LinkElementsCommand::LinkElementsCommand(Element *elmt1, Element *elmt2, QUndoCo
diagram_(elmt1->diagram()), diagram_(elmt1->diagram()),
elmt_1(elmt1), elmt_1(elmt1),
elmt_2(elmt2), elmt_2(elmt2),
previous_report(0) previous_report(0),
first_redo(true)
{ {
if (elmt1->linkType() & Element::AllReport && if (elmt1->linkType() & Element::AllReport &&
elmt2->linkType() & Element::AllReport) { elmt2->linkType() & Element::AllReport) {
@@ -1189,6 +1191,13 @@ void LinkElementsCommand::undo() {
void LinkElementsCommand::redo() { void LinkElementsCommand::redo() {
diagram_->showMe(); diagram_->showMe();
elmt_1->linkToElement(elmt_2); 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;
}
} }
/** /**

View File

@@ -600,6 +600,7 @@ class LinkElementsCommand : public QUndoCommand {
//attributes //attributes
Diagram *diagram_; Diagram *diagram_;
Element *elmt_1, *elmt_2, *previous_report; Element *elmt_1, *elmt_2, *previous_report;
bool first_redo;
}; };
class unlinkElementsCommand : public QUndoCommand { class unlinkElementsCommand : public QUndoCommand {

View File

@@ -1395,6 +1395,7 @@ Terminal * Conductor::relatedPotentialTerminal (Terminal *t) {
* @return l'editeur de schemas parent ou 0 * @return l'editeur de schemas parent ou 0
*/ */
QETDiagramEditor* Conductor::diagramEditor() const { QETDiagramEditor* Conductor::diagramEditor() const {
if (diagram()->views().isEmpty()) return 0;
QWidget *w = const_cast<QGraphicsView *>(diagram() -> views().at(0)); QWidget *w = const_cast<QGraphicsView *>(diagram() -> views().at(0));
while (w -> parentWidget() && !w -> isWindow()) { while (w -> parentWidget() && !w -> isWindow()) {
w = w -> parentWidget(); w = w -> parentWidget();

View File

@@ -19,7 +19,6 @@
#include "elementtextitem.h" #include "elementtextitem.h"
#include "diagramposition.h" #include "diagramposition.h"
#include "qetproject.h" #include "qetproject.h"
#include "conductorautonumerotation.h"
ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) : ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) :
CustomElement(location, qgi, s, state) CustomElement(location, qgi, s, state)
@@ -50,7 +49,7 @@ void ReportElement::linkToElement(Element * elmt) {
if (connected_elements.first() == elmt) i = false; 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) { if ((elmt->linkType() == inverse_report) && i) {
unlinkAllElements(); unlinkAllElements();
connected_elements << elmt; connected_elements << elmt;
@@ -58,10 +57,6 @@ void ReportElement::linkToElement(Element * elmt) {
connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel()));
updateLabel(); updateLabel();
elmt->linkToElement(this); elmt->linkToElement(this);
//Check if text of this potential is identical.
if (conductors().count() && elmt->conductors().count()) {
ConductorAutoNumerotation::checkPotential(conductors().first());
}
} }
} }