mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Delete open databases when DatabaseTabWidget is destructed.
This commit is contained in:
parent
9ae6d2cd05
commit
ca13ad8d25
@ -53,6 +53,15 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||
connect(this, SIGNAL(currentChanged(int)), SLOT(emitEntrySelectionChanged()));
|
||||
}
|
||||
|
||||
DatabaseTabWidget::~DatabaseTabWidget()
|
||||
{
|
||||
QHashIterator<Database*, DatabaseManagerStruct> i(m_dbList);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
deleteDatabase(i.key());
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::toggleTabbar() {
|
||||
if (count() > 1) {
|
||||
if (!tabBar()->isVisible()) {
|
||||
@ -201,13 +210,22 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
}
|
||||
}
|
||||
|
||||
deleteDatabase(db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::deleteDatabase(Database* db)
|
||||
{
|
||||
const DatabaseManagerStruct dbStruct = m_dbList.value(db);
|
||||
int index = databaseIndex(db);
|
||||
|
||||
removeTab(index);
|
||||
toggleTabbar();
|
||||
m_dbList.remove(db);
|
||||
delete dbStruct.file;
|
||||
delete dbStruct.dbWidget;
|
||||
delete db;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DatabaseTabWidget::closeAllDatabases() {
|
||||
|
@ -47,6 +47,7 @@ class DatabaseTabWidget : public QTabWidget
|
||||
|
||||
public:
|
||||
explicit DatabaseTabWidget(QWidget* parent);
|
||||
~DatabaseTabWidget();
|
||||
void openDatabase(const QString& fileName, const QString& pw = QString(),
|
||||
const QString& keyFile = QString());
|
||||
DatabaseWidget* currentDatabaseWidget();
|
||||
@ -93,6 +94,7 @@ private:
|
||||
void saveDatabase(Database* db);
|
||||
void saveDatabaseAs(Database* db);
|
||||
bool closeDatabase(Database* db);
|
||||
void deleteDatabase(Database* db);
|
||||
int databaseIndex(Database* db);
|
||||
Database* indexDatabase(int index);
|
||||
DatabaseManagerStruct indexDatabaseManagerStruct(int index);
|
||||
|
Loading…
Reference in New Issue
Block a user