diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-06-08 13:58:33 +0200 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-06-08 14:10:46 +0200 |
commit | d547e84c9335d9524ae7530be622d5ed2f0b1fb8 (patch) | |
tree | 193bd0337941033018df2390ee3f9bc389c67db5 /lib | |
parent | c566c94cc8db0401c30e6e047110d514bae1fa36 (diff) | |
download | libquotient-d547e84c9335d9524ae7530be622d5ed2f0b1fb8.tar.gz libquotient-d547e84c9335d9524ae7530be622d5ed2f0b1fb8.zip |
Save connection state while QCoreApplication is still there
This reimplements #558 in a more reliable way. Deconstruction of
AccountRegistry may (or may not, yay for static initialisation) occur
after deconstruction of QCoreApplication, in which case an attempt
to determine the directory for the state fails because it depends on
the application object existence.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/accountregistry.cpp | 7 | ||||
-rw-r--r-- | lib/accountregistry.h | 2 | ||||
-rw-r--r-- | lib/connection.cpp | 1 |
3 files changed, 1 insertions, 9 deletions
diff --git a/lib/accountregistry.cpp b/lib/accountregistry.cpp index 2cab54a3..ad7c5f99 100644 --- a/lib/accountregistry.cpp +++ b/lib/accountregistry.cpp @@ -135,10 +135,3 @@ QStringList AccountRegistry::accountsLoading() const { return m_accountsLoading; } - -AccountRegistry::~AccountRegistry() -{ - for (const auto& connection : *this) { - connection->saveState(); - } -} diff --git a/lib/accountregistry.h b/lib/accountregistry.h index 959c7d42..38cfe6c6 100644 --- a/lib/accountregistry.h +++ b/lib/accountregistry.h @@ -42,8 +42,6 @@ public: [[deprecated("Use Accounts variable instead")]] // static AccountRegistry& instance(); - ~AccountRegistry(); - // Expose most of QVector's const-API but only provide add() and drop() // for changing it. In theory other changing operations could be supported // too; but then boilerplate begin/end*() calls has to be tucked into each diff --git a/lib/connection.cpp b/lib/connection.cpp index 7885718f..101bef89 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -611,6 +611,7 @@ void Connection::Private::completeSetup(const QString& mxId) << "by user" << data->userId() << "from device" << data->deviceId(); Accounts.add(q); + connect(qApp, &QCoreApplication::aboutToQuit, q, &Connection::saveState); #ifndef Quotient_E2EE_ENABLED qCWarning(E2EE) << "End-to-end encryption (E2EE) support is turned off."; #else // Quotient_E2EE_ENABLED |