Fix crash when Sip registration failed upon login
This commit is contained in:
parent
f58a1a48e5
commit
727c53209b
2 changed files with 14 additions and 32 deletions
|
|
@ -124,14 +124,21 @@ bool AccountManager::login(QString username,
|
||||||
mAccountModel = Utils::makeQObject_ptr<AccountModel>(account);
|
mAccountModel = Utils::makeQObject_ptr<AccountModel>(account);
|
||||||
mAccountModel->setSelf(mAccountModel);
|
mAccountModel->setSelf(mAccountModel);
|
||||||
connect(mAccountModel.get(), &AccountModel::registrationStateChanged, this,
|
connect(mAccountModel.get(), &AccountModel::registrationStateChanged, this,
|
||||||
[this, authInfo](const std::shared_ptr<linphone::Account> &account, linphone::RegistrationState state,
|
[this, authInfo, core](const std::shared_ptr<linphone::Account> &account, linphone::RegistrationState state,
|
||||||
const std::string &message) {
|
const std::string &message) {
|
||||||
if (account == mAccountModel->getAccount() && state == linphone::RegistrationState::Failed) {
|
if (mAccountModel && account == mAccountModel->getAccount()) {
|
||||||
auto core = CoreModel::getInstance()->getCore();
|
if (state == linphone::RegistrationState::Failed) {
|
||||||
core->removeAuthInfo(authInfo);
|
core->removeAuthInfo(authInfo);
|
||||||
core->removeAccount(account);
|
core->removeAccount(account);
|
||||||
|
emit mAccountModel->removeListener();
|
||||||
|
mAccountModel = nullptr;
|
||||||
|
} else if (state == linphone::RegistrationState::Ok) {
|
||||||
|
core->setDefaultAccount(account);
|
||||||
|
emit mAccountModel->removeListener();
|
||||||
|
mAccountModel = nullptr;
|
||||||
}
|
}
|
||||||
emit onRegistrationStateChanged(account, state, message);
|
}
|
||||||
|
emit registrationStateChanged(state);
|
||||||
});
|
});
|
||||||
auto status = core->addAccount(account);
|
auto status = core->addAccount(account);
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
|
|
@ -314,24 +321,3 @@ void AccountManager::linkNewAccountUsingCode(const QString &code,
|
||||||
mAccountManagerServicesModel->linkPhoneNumberToAccountUsingCode(sipIdentityAddress,
|
mAccountManagerServicesModel->linkPhoneNumberToAccountUsingCode(sipIdentityAddress,
|
||||||
Utils::appStringToCoreString(code));
|
Utils::appStringToCoreString(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
|
||||||
linphone::RegistrationState state,
|
|
||||||
const std::string &message) {
|
|
||||||
auto core = CoreModel::getInstance()->getCore();
|
|
||||||
switch (state) {
|
|
||||||
case linphone::RegistrationState::Failed:
|
|
||||||
core->removeAccount(account);
|
|
||||||
emit mAccountModel->removeListener();
|
|
||||||
mAccountModel = nullptr;
|
|
||||||
break;
|
|
||||||
case linphone::RegistrationState::Ok:
|
|
||||||
core->setDefaultAccount(account);
|
|
||||||
emit mAccountModel->removeListener();
|
|
||||||
mAccountModel = nullptr;
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit registrationStateChanged(state);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,6 @@ public:
|
||||||
|
|
||||||
void linkNewAccountUsingCode(const QString &code, RegisterType registerType, const QString &sipAddress);
|
void linkNewAccountUsingCode(const QString &code, RegisterType registerType, const QString &sipAddress);
|
||||||
|
|
||||||
void onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
|
||||||
linphone::RegistrationState state,
|
|
||||||
const std::string &message);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void registrationStateChanged(linphone::RegistrationState state);
|
void registrationStateChanged(linphone::RegistrationState state);
|
||||||
void newAccountCreationSucceed(QString sipAddress, RegisterType registerType, const QString ®isterAddress);
|
void newAccountCreationSucceed(QString sipAddress, RegisterType registerType, const QString ®isterAddress);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue