mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Fix crash
See bug N°244 https://qelectrotech.org/bugtracker/view.php?id=244
This commit is contained in:
parent
67637acaab
commit
0f95edc5e6
@ -120,8 +120,19 @@ QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
||||
*/
|
||||
QETProject::~QETProject()
|
||||
{
|
||||
for (auto diagram : m_diagrams_list)
|
||||
//Each time a diagram is deleted we also remove it from m_diagram_list
|
||||
//because a lot of thing append during the destructor of a diagram class
|
||||
//and one of these thing (not directly in the destructor of the diagram
|
||||
//but in another destructor called by the diagram destructor)
|
||||
//is to get the diagram list of the project to make some updates @see QList<Diagram *> QETProject::diagrams() const.
|
||||
//So we need to remove the freshly deleted diagram from the list
|
||||
//in each iteration of the loop to avoid the use of a dangling pointer.
|
||||
const auto diag_list = m_diagrams_list;
|
||||
for (const auto &diagram : diag_list)
|
||||
{
|
||||
delete diagram;
|
||||
m_diagrams_list.removeOne(diagram);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user