From 3577c71193979fec2aaa26d6802dd0055873cc54 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Thu, 31 Oct 2019 20:44:22 +0100 Subject: [PATCH] Allow closing the last tab by opening a new clean one This allows clearing all the SQL tabs and at the same time, avoids leaving an empty SQL tab widget. Related to issue #2025 --- src/MainWindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index d39db819..522681fd 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1827,10 +1827,6 @@ bool MainWindow::askSaveSqlTab(int index, bool& ignoreUnattachedBuffers) void MainWindow::closeSqlTab(int index, bool force) { - // Don't close last tab - if(ui->tabSqlAreas->count() == 1 && !force) - return; - // Check if we're still executing statements from this tab and stop them before proceeding if(!ui->tabSqlAreas->tabIcon(index).isNull()) { @@ -1852,6 +1848,10 @@ void MainWindow::closeSqlTab(int index, bool force) QWidget* w = ui->tabSqlAreas->widget(index); ui->tabSqlAreas->removeTab(index); delete w; + + // Don't let an empty tab widget + if(ui->tabSqlAreas->count() == 0 && !force) + openSqlTab(true); } int MainWindow::openSqlTab(bool resetCounter)