Prevent crashes creating contacts with only phone number and no SIP address

This commit is contained in:
Christophe Deschamps 2025-01-29 17:12:14 +01:00
parent 5d42559f83
commit 8003b09e3b
2 changed files with 4 additions and 3 deletions

View file

@ -100,7 +100,7 @@ void MagicSearchModel::onSearchResultsReceived(const std::shared_ptr<linphone::M
auto resultIt =
std::find_if(finalResults.begin(), finalResults.end(), [result](std::shared_ptr<linphone::SearchResult> r) {
return r->getAddress()->weakEqual(result->getAddress());
return r->getAddress() && r->getAddress()->weakEqual(result->getAddress());
});
if (resultIt == finalResults.end()) finalResults.push_back(result);
else if (fList && fList->getDisplayName() == "app_friends") *resultIt = result; // replace if local friend
@ -142,5 +142,5 @@ void MagicSearchModel::updateFriendListWithFriend(const std::shared_ptr<linphone
}
qDebug() << log().arg("Adding Friend:") << linphoneFriend.get();
friendList->addFriend(linphoneFriend);
emit CoreModel::getInstance()->friendCreated(linphoneFriend);
emit CoreModel::getInstance() -> friendCreated(linphoneFriend);
}

View file

@ -364,7 +364,8 @@ VariantObject *Utils::findAvatarByAddress(const QString &address) {
});
// Rebuild avatar if needed
auto updateValue = [data, address](const std::shared_ptr<linphone::Friend> &f) -> void {
if (f && f->getAddress()->weakEqual(ToolModel::interpretUrl(address))) data->invokeRequestValue();
if (f && f->getAddress() && f->getAddress()->weakEqual(ToolModel::interpretUrl(address)))
data->invokeRequestValue();
};
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendCreated, updateValue);
data->makeUpdateCond(CoreModel::getInstance().get(), &CoreModel::friendRemoved, updateValue);