From d6c0003f7589e83c8f9ac6734f9b27554358a9f5 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Thu, 22 Nov 2018 22:09:15 +0100 Subject: deferred deletion for all (potential) listeners --- src/data/tikzdocument.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/data/tikzdocument.cpp') diff --git a/src/data/tikzdocument.cpp b/src/data/tikzdocument.cpp index 24a793b..863f1fd 100644 --- a/src/data/tikzdocument.cpp +++ b/src/data/tikzdocument.cpp @@ -34,16 +34,10 @@ TikzDocument::TikzDocument(QObject *parent) : QObject(parent) _parseSuccess = true; _fileName = ""; _shortName = ""; - _undoStack = new QUndoStack(); + _undoStack = new QUndoStack(this); _undoStack->setClean(); } -TikzDocument::~TikzDocument() -{ - delete _graph; - delete _undoStack; -} - QUndoStack *TikzDocument::undoStack() const { return _undoStack; @@ -79,11 +73,12 @@ void TikzDocument::open(QString fileName) _tikz = in.readAll(); file.close(); + Graph *oldGraph = _graph; Graph *newGraph = new Graph(this); TikzAssembler ass(newGraph); if (ass.parse(_tikz)) { - delete _graph; _graph = newGraph; + oldGraph->deleteLater(); foreach (Node *n, _graph->nodes()) n->attachStyle(); foreach (Edge *e, _graph->edges()) { e->attachStyle(); @@ -93,7 +88,7 @@ void TikzDocument::open(QString fileName) refreshTikz(); setClean(); } else { - delete newGraph; + newGraph->deleteLater(); _parseSuccess = false; } } -- cgit v1.2.3