From ef2a48341302570093e61cda09e87158f0aecff2 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Fri, 30 Apr 2021 17:28:13 -0400 Subject: [PATCH] newaccountmodel: close the account database when removing the account Change-Id: I9e3addc57f1a84112dbaf300fc448d60b7ef6224 --- src/database.cpp | 16 +++++++++++++--- src/database.h | 2 ++ src/newaccountmodel.cpp | 8 ++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/database.cpp b/src/database.cpp index d3dec5b8..e2c1b50f 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -80,15 +80,25 @@ Database::Database(const QString& name, const QString& basePath) db_.setDatabaseName(databaseFullPath_); } -Database::~Database() {} +Database::~Database() +{ + close(); +} void -Database::remove() +Database::close() { - // close db and remove file + // close db if (db_.isOpen()) { db_.close(); } +} + +void +Database::remove() +{ + // close db and remove file + close(); QFile(databaseFullPath_).remove(); } diff --git a/src/database.h b/src/database.h index 7b153d51..6802ff55 100644 --- a/src/database.h +++ b/src/database.h @@ -60,6 +60,8 @@ public: void remove(); + void close(); + virtual void load(); /** diff --git a/src/newaccountmodel.cpp b/src/newaccountmodel.cpp index b65c16b5..512dffd5 100644 --- a/src/newaccountmodel.cpp +++ b/src/newaccountmodel.cpp @@ -319,6 +319,7 @@ NewAccountModel::exportOnRing(const QString& accountId, const QString& password) void NewAccountModel::removeAccount(const QString& accountId) const { + pimpl_->accounts.erase(accountId); ConfigurationManager::instance().removeAccount(accountId); } @@ -837,7 +838,8 @@ account::Info::fromDetails(const MapStringString& details) confProperties.bootstrapListUrl = QString(details[ConfProperties::BOOTSTRAP_LIST_URL]); confProperties.dhtProxyListUrl = QString(details[ConfProperties::DHT_PROXY_LIST_URL]); confProperties.defaultModerators = QString(details[ConfProperties::DEFAULT_MODERATORS]); - confProperties.localModeratorsEnabled = toBool(details[ConfProperties::LOCAL_MODERATORS_ENABLED]); + confProperties.localModeratorsEnabled = toBool( + details[ConfProperties::LOCAL_MODERATORS_ENABLED]); // Audio confProperties.Audio.audioPortMax = toInt(details[ConfProperties::Audio::PORT_MAX]); confProperties.Audio.audioPortMin = toInt(details[ConfProperties::Audio::PORT_MIN]); @@ -1157,7 +1159,9 @@ NewAccountModel::bestIdForAccount(const QString& accountID) } void -NewAccountModel::setDefaultModerator(const QString& accountID, const QString& peerURI, const bool& state) +NewAccountModel::setDefaultModerator(const QString& accountID, + const QString& peerURI, + const bool& state) { ConfigurationManager::instance().setDefaultModerator(accountID, peerURI, state); } -- GitLab