From 2db0208ed333e0bf232e396c1789085781f50d66 Mon Sep 17 00:00:00 2001
From: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Date: Mon, 1 Jul 2019 14:43:19 +0200
Subject: Correct order of operations during editor close.

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
---
 qtmips_gui/mainwindow.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'qtmips_gui')

diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 4ad3b0f..241a623 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -533,9 +533,10 @@ void MainWindow::save_source() {
 void MainWindow::close_source() {
     if (current_srceditor == nullptr)
         return;
-    int idx = central_window->indexOf(current_srceditor);
+    SrcEditor *editor = current_srceditor;
+    setCurrentSrcEditor(nullptr);
+    int idx = central_window->indexOf(editor);
     if (idx >= 0)
         central_window->removeTab(idx);
-    delete current_srceditor;
-    current_srceditor = nullptr;
+    delete editor;
 }
-- 
cgit v1.2.3