mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Fix crash when close project
At time of closing project, if a master element(may be every linkable element) is selected and the editor dock display a lot of available slave, qet crash.
This commit is contained in:
@@ -101,7 +101,6 @@ DiagramView::DiagramView(Diagram *diagram, QWidget *parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(m_diagram, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
|
connect(m_diagram, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
|
||||||
connect(m_diagram, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
|
|
||||||
connect(m_diagram, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(adjustSceneRect()));
|
connect(m_diagram, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(adjustSceneRect()));
|
||||||
connect(&(m_diagram -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
connect(&(m_diagram -> border_and_titleblock), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||||
connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation)));
|
connect(diagram, SIGNAL(editElementRequired(ElementsLocation)), this, SIGNAL(editElementRequired(ElementsLocation)));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2019 The QElectroTech Team
|
Copyright 2006-2019 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -102,8 +102,6 @@ class DiagramView : public QGraphicsView
|
|||||||
bool gestures() const;
|
bool gestures() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// Signal emitted after the selection changed
|
|
||||||
void selectionChanged();
|
|
||||||
/// Signal emitted after the selection mode changed
|
/// Signal emitted after the selection mode changed
|
||||||
void modeChanged();
|
void modeChanged();
|
||||||
/// Signal emitted after the diagram title changed
|
/// Signal emitted after the diagram title changed
|
||||||
|
|||||||
@@ -56,11 +56,8 @@ ProjectView::ProjectView(QETProject *project, QWidget *parent) :
|
|||||||
Supprime les DiagramView embarquees
|
Supprime les DiagramView embarquees
|
||||||
*/
|
*/
|
||||||
ProjectView::~ProjectView() {
|
ProjectView::~ProjectView() {
|
||||||
// qDebug() << "Suppression du ProjectView" << ((void *)this);
|
for (auto dv_ : m_diagram_ids.values())
|
||||||
foreach(int id, m_diagram_ids.keys()) {
|
dv_->deleteLater();
|
||||||
DiagramView *diagram_view = m_diagram_ids.take(id);
|
|
||||||
delete diagram_view;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1932,17 +1932,26 @@ void QETDiagramEditor::activateProject(ProjectView *project_view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere la fermeture d'une ProjectView
|
* @brief QETDiagramEditor::projectWasClosed
|
||||||
@param project_view ProjectView fermee
|
* Manage the close of a project.
|
||||||
*/
|
* @param project_view
|
||||||
void QETDiagramEditor::projectWasClosed(ProjectView *project_view) {
|
*/
|
||||||
|
void QETDiagramEditor::projectWasClosed(ProjectView *project_view)
|
||||||
|
{
|
||||||
QETProject *project = project_view -> project();
|
QETProject *project = project_view -> project();
|
||||||
if (project) {
|
if (project)
|
||||||
|
{
|
||||||
pa -> elementsPanel().projectWasClosed(project);
|
pa -> elementsPanel().projectWasClosed(project);
|
||||||
m_element_collection_widget->removeProject(project);
|
m_element_collection_widget->removeProject(project);
|
||||||
undo_group.removeStack(project -> undoStack());
|
undo_group.removeStack(project -> undoStack());
|
||||||
QETApp::unregisterProject(project);
|
QETApp::unregisterProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//When project is closed, a lot of signal are emited, notably if there is an item selected in a diagram.
|
||||||
|
//In some special case, since signal/slot connection can be direct or queued, some signal are handled after QObject is deleted, and crash qet
|
||||||
|
//notably in the function Diagram::elements when she call items() (I don't know exactly why).
|
||||||
|
//set nullptr to "m_selection_properties_editor->setDiagram()" fix this crash
|
||||||
|
m_selection_properties_editor->setDiagram(nullptr);
|
||||||
project_view -> deleteLater();
|
project_view -> deleteLater();
|
||||||
project -> deleteLater();
|
project -> deleteLater();
|
||||||
}
|
}
|
||||||
@@ -2147,7 +2156,7 @@ void QETDiagramEditor::removeDiagramFromProject() {
|
|||||||
*/
|
*/
|
||||||
void QETDiagramEditor::diagramWasAdded(DiagramView *dv)
|
void QETDiagramEditor::diagramWasAdded(DiagramView *dv)
|
||||||
{
|
{
|
||||||
connect(dv, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
connect(dv->diagram(), &QGraphicsScene::selectionChanged, this, &QETDiagramEditor::selectionChanged, Qt::DirectConnection);
|
||||||
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
connect(dv, SIGNAL(modeChanged()), this, SLOT(slot_updateModeActions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user