From 4885535c9e1da9b1a718125273bfe76933c7fff8 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 17 Jul 2019 19:53:33 +0200 Subject: Do not open editor twice for same filename. Signed-off-by: Pavel Pisa --- qtmips_gui/mainwindow.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 87549d2..19299c0 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -584,7 +584,14 @@ void MainWindow::open_source() { file_name = QFileDialog::getOpenFileName(this, tr("Open File"), "", "Source Files (*.asm *.S *.s)"); if (!file_name.isEmpty()) { - SrcEditor *editor = new SrcEditor(); + SrcEditor *editor = source_editor_for_file(file_name, false); + if (editor != nullptr) { + if (central_window != nullptr) + central_window->setCurrentWidget(editor); + return; + } + editor = new SrcEditor(); + if (editor->loadFile(file_name)) { add_src_editor_to_tabs(editor); } else { -- cgit v1.2.3