Assert validity of accountstate and its accountptr when adding it

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-06-25 18:22:30 +08:00
parent 74a78242e2
commit 1689f7b613
2 changed files with 6 additions and 5 deletions

View file

@ -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;

View file

@ -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<AccountStatePtr> _accounts;