fix that connection are only closed when the window is closed not when the tab owning them is closed.

Caused by the fact the the tab was not freed. Now the widgets on the tabs are freed when they are closed which
in turns frees (and closes) the connection objects.
This commit is contained in:
eelke 2021-09-17 18:55:10 +02:00
parent 683853e72e
commit 144321a5d3
2 changed files with 6 additions and 2 deletions

View file

@ -28,7 +28,7 @@ CrudTab::CrudTab(IDatabaseWindow *context, QWidget *parent)
auto delegate = new PgLabItemDelegate(ui->tableView);
ui->tableView->setItemDelegate(delegate);
m_crudModel = new CrudModel(parent);
m_crudModel = new CrudModel(nullptr);
m_SortFilterProxy = new QSortFilterProxyModel(this);
m_SortFilterProxy->setSourceModel(m_crudModel);
@ -48,6 +48,7 @@ CrudTab::CrudTab(IDatabaseWindow *context, QWidget *parent)
CrudTab::~CrudTab()
{
delete m_crudModel;
delete ui;
}

View file

@ -281,8 +281,11 @@ void DatabaseWindow::closeTab(int index)
if (index < 0)
return;
if (canCloseTab(index))
if (canCloseTab(index)) {
QWidget *widget = m_tabWidget->widget(index);
m_tabWidget->removeTab(index);
delete widget;
}
}
bool DatabaseWindow::canCloseTab(int index) const