mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
try to fix read access violation (Mantis 0013842)
This commit is contained in:
parent
0614520e5a
commit
672ae55ea6
3 changed files with 15 additions and 10 deletions
|
|
@ -83,15 +83,19 @@ void MagicSearchModel::onSearchResultsReceived(const std::shared_ptr<linphone::M
|
|||
auto ldapFriends = ToolModel::getLdapFriendList();
|
||||
emit searchResultsReceived(results);
|
||||
for (auto result : results) {
|
||||
if (!result) continue;
|
||||
auto f = result->getFriend();
|
||||
auto friendsManager = FriendsManager::getInstance();
|
||||
if (f) {
|
||||
qDebug() << "friend exists, append to unknown map";
|
||||
auto friendAddress = f->getAddress()->clone();
|
||||
friendAddress->clean();
|
||||
friendsManager->appendUnknownFriend(friendAddress, f);
|
||||
if (friendsManager->isInOtherAddresses(Utils::coreStringToAppString(friendAddress->asStringUriOnly()))) {
|
||||
friendsManager->removeOtherAddress(Utils::coreStringToAppString(friendAddress->asStringUriOnly()));
|
||||
auto friendAddress = f->getAddress() ? f->getAddress()->clone() : nullptr;
|
||||
if (friendAddress) {
|
||||
friendAddress->clean();
|
||||
friendsManager->appendUnknownFriend(friendAddress, f);
|
||||
if (friendsManager->isInOtherAddresses(
|
||||
Utils::coreStringToAppString(friendAddress->asStringUriOnly()))) {
|
||||
friendsManager->removeOtherAddress(Utils::coreStringToAppString(friendAddress->asStringUriOnly()));
|
||||
}
|
||||
}
|
||||
}
|
||||
auto fList = f ? f->getFriendList() : nullptr;
|
||||
|
|
@ -128,7 +132,7 @@ void MagicSearchModel::updateFriendListWithFriend(const std::shared_ptr<linphone
|
|||
if (ToolModel::friendIsInFriendList(friendList, linphoneFriend))
|
||||
return; // Already exist. We don't need to manipulate list.
|
||||
for (auto address : linphoneFriend->getAddresses()) {
|
||||
auto existingFriend = friendList->findFriendByAddress(address);
|
||||
auto existingFriend = friendList ? friendList->findFriendByAddress(address) : nullptr;
|
||||
if (existingFriend) {
|
||||
friendList->removeFriend(existingFriend);
|
||||
friendList->addFriend(linphoneFriend);
|
||||
|
|
@ -136,7 +140,7 @@ void MagicSearchModel::updateFriendListWithFriend(const std::shared_ptr<linphone
|
|||
}
|
||||
}
|
||||
for (auto number : linphoneFriend->getPhoneNumbers()) {
|
||||
auto existingFriend = friendList->findFriendByPhoneNumber(number);
|
||||
auto existingFriend = friendList ? friendList->findFriendByPhoneNumber(number) : nullptr;
|
||||
if (existingFriend) {
|
||||
friendList->removeFriend(existingFriend);
|
||||
friendList->addFriend(linphoneFriend);
|
||||
|
|
@ -144,6 +148,6 @@ void MagicSearchModel::updateFriendListWithFriend(const std::shared_ptr<linphone
|
|||
}
|
||||
}
|
||||
qInfo() << log().arg("Adding Friend:") << linphoneFriend.get();
|
||||
friendList->addFriend(linphoneFriend);
|
||||
if (friendList) friendList->addFriend(linphoneFriend);
|
||||
emit CoreModel::getInstance()->friendCreated(linphoneFriend);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "ToolModel.hpp"
|
||||
#include "core/App.hpp"
|
||||
#include "core/conference/ConferenceInfoCore.hpp"
|
||||
#include "core/path/Paths.hpp"
|
||||
#include "model/core/CoreModel.hpp"
|
||||
#include "model/friend/FriendsManager.hpp"
|
||||
|
|
@ -28,7 +29,6 @@
|
|||
#include <QDirIterator>
|
||||
#include <QLibrary>
|
||||
#include <QTest>
|
||||
#include "core/conference/ConferenceInfoCore.hpp"
|
||||
|
||||
DEFINE_ABSTRACT_OBJECT(ToolModel)
|
||||
|
||||
|
|
@ -379,6 +379,7 @@ std::shared_ptr<linphone::FriendList> ToolModel::getLdapFriendList() {
|
|||
|
||||
bool ToolModel::friendIsInFriendList(const std::shared_ptr<linphone::FriendList> &friendList,
|
||||
const std::shared_ptr<linphone::Friend> &f) {
|
||||
if (!friendList) return false;
|
||||
auto friends = friendList->getFriends();
|
||||
auto it = std::find_if(friends.begin(), friends.end(),
|
||||
[f](std::shared_ptr<linphone::Friend> linFriend) { return linFriend == f; });
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ ListView {
|
|||
|
||||
header: Item {
|
||||
visible: mainItem.chat && mainItem.chat.core.isEncrypted
|
||||
height: headerMessage.height + Math.round(50 * DefaultStyle.dp)
|
||||
height: visible ? headerMessage.height + Math.round(50 * DefaultStyle.dp) : 0
|
||||
width: headerMessage.width
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Control.Control {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue