From: Claudio Cambra Date: Tue, 25 Jun 2024 10:22:30 +0000 (+0800) Subject: Assert validity of accountstate and its accountptr when adding it X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~7^2~13^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9948fed554031f9eb586861a466ed533c781be9c;p=nextcloud-desktop.git Assert validity of accountstate and its accountptr when adding it Signed-off-by: Claudio Cambra --- diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 2425581b3..8a2f3bb38 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -568,11 +568,12 @@ QString AccountManager::generateFreeAccountId() const } } -void AccountManager::addAccountState(AccountState *accountState) +void AccountManager::addAccountState(AccountState *const accountState) { - QObject::connect(accountState->account().data(), - &Account::wantsAccountSaved, - this, &AccountManager::saveAccount); + Q_ASSERT(accountState); + Q_ASSERT(accountState->account()); + + QObject::connect(accountState->account().data(), &Account::wantsAccountSaved, this, &AccountManager::saveAccount); AccountStatePtr ptr(accountState); _accounts << ptr; diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h index 626800f9b..32b7ca8e4 100644 --- a/src/gui/accountmanager.h +++ b/src/gui/accountmanager.h @@ -126,7 +126,7 @@ private: [[nodiscard]] QString generateFreeAccountId() const; // Adds an account to the tracked list, emitting accountAdded() - void addAccountState(AccountState *accountState); + void addAccountState(AccountState *const accountState); AccountManager() = default; QList _accounts;