From 144321a5d33f74f77835ad35430f728cc21ee9e8 Mon Sep 17 00:00:00 2001 From: eelke Date: Fri, 17 Sep 2021 18:55:10 +0200 Subject: [PATCH] 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. --- pglab/CrudTab.cpp | 3 ++- pglab/DatabaseWindow.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pglab/CrudTab.cpp b/pglab/CrudTab.cpp index f44b0a1..c50d7c8 100644 --- a/pglab/CrudTab.cpp +++ b/pglab/CrudTab.cpp @@ -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; } diff --git a/pglab/DatabaseWindow.cpp b/pglab/DatabaseWindow.cpp index a8dbf57..201a414 100644 --- a/pglab/DatabaseWindow.cpp +++ b/pglab/DatabaseWindow.cpp @@ -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