mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
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:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define CONDUCTORAUTONUMEROTATIONWIDGET_H
|
||||
|
||||
#include <QtGui>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QMultiMap>
|
||||
#include <QString>
|
||||
@@ -13,7 +12,7 @@ class ConductorAutoNumerotationWidget : public QDialog
|
||||
{
|
||||
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 @@ class ConductorAutoNumerotationWidget : public QDialog
|
||||
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_;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<QGraphicsView *>(diagram() -> views().at(0));
|
||||
while (w -> parentWidget() && !w -> isWindow()) {
|
||||
w = w -> parentWidget();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user