Commit bd8b3b1c authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

Followup to commit 9d9800c3 fix for crash on exit with tabbed diagrams

There was a further crash on closing in the code path
  UMLApp::slotFileClose() => slotFileNew() => m_doc->newDocument()
due to DiagramsModel::m_views not having been reset to empty.
This caused access to stale UMLView objects already deconstructed.

umbrello/models/diagramsmodel.{h,cpp}
- New function removeAllDiagrams clears content of m_views.

umbrello/uml.cpp
- In function slotFileClose call diagramsModel()->removeAllDiagrams()
  on m_doc before calling slotFileNew().

CCBUG: 430322
parent 1a9d3283
......@@ -117,6 +117,16 @@ bool DiagramsModel::removeDiagram(UMLView *view)
return true;
}
bool DiagramsModel::removeAllDiagrams()
{
if (!m_views.count())
return false;
beginRemoveRows(QModelIndex(), 0, m_views.count() - 1);
m_views.clear();
endRemoveRows();
return true;
}
void DiagramsModel::emitDataChanged(const QModelIndex &index)
{
emit dataChanged(index, index);
......
......@@ -36,6 +36,7 @@ public:
bool addDiagram(UMLView *view);
bool removeDiagram(UMLView *view);
bool removeAllDiagrams();
void emitDataChanged(const QModelIndex &index);
void emitDataChanged(int index);
......
......@@ -27,6 +27,7 @@
#include "umbrellosettings.h"
#include "statusbartoolbutton.h"
#include "findresults.h"
#include "models/diagramsmodel.h"
// code generation
#include "advancedcodegenerator.h"
......@@ -1429,6 +1430,7 @@ bool UMLApp::slotFileSaveAs()
void UMLApp::slotFileClose()
{
slotStatusMsg(i18n("Closing file..."));
m_doc->diagramsModel()->removeAllDiagrams();
slotFileNew();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment