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
This commit is contained in:
mgrojo
2019-10-31 20:44:22 +01:00
parent e2081db019
commit 3577c71193

View File

@@ -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)