diff --git a/src/authority/storagehelper.cpp b/src/authority/storagehelper.cpp index 41ae87cec1da96159f4534952335c2e71ca0c8b2..d81101964ca0ade17b9712a3442ca0931262e7f9 100644 --- a/src/authority/storagehelper.cpp +++ b/src/authority/storagehelper.cpp @@ -356,10 +356,8 @@ getAccountAvatar(const QString& accountId) QString filePath; filePath = accountLocalPath + "profile.vcf"; QFile file(filePath); - if (!file.open(QIODevice::ReadOnly)) { - qWarning() << "Can't open file: " << filePath; + if (!file.open(QIODevice::ReadOnly)) return {}; - } const auto vCard = lrc::vCard::utils::toHashMap(file.readAll()); const auto photo = (vCard.find(vCard::Property::PHOTO_PNG) == vCard.end()) ? vCard[vCard::Property::PHOTO_JPEG] @@ -384,7 +382,6 @@ buildContactFromProfile(const QString& accountId, QString filePath = accountLocalPath + "profiles/" + peer_uri + ".vcf"; file.setFileName(filePath); if (!file.open(QIODevice::ReadOnly)) { - qWarning().noquote() << "Can't open file: " << filePath; return {profileInfo, "", true, false}; } // rename it diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp index fa98b7f171e7c2c4c60a8ac9ea8c4fd184b6188a..0f043043c5573b96ebf5a6da0e5a1c95978d5979 100644 --- a/src/contactmodel.cpp +++ b/src/contactmodel.cpp @@ -523,18 +523,15 @@ ContactModel::sendDhtMessage(const QString& contactUri, const QString& body) con const QString ContactModel::bestNameForContact(const QString& contactUri) const { - try { - auto contact = getContact(contactUri); + std::lock_guard<std::mutex> lk(pimpl_->contactsMtx_); + if (pimpl_->contacts.contains(contactUri)) { + auto contact = pimpl_->contacts.value(contactUri); auto alias = contact.profileInfo.alias.simplified(); - if (alias.isEmpty()) { return bestIdFromContactInfo(contact); } return alias; - } catch (const std::out_of_range& e) { - qDebug() << "ContactModel::bestNameForContact" << e.what(); } - return contactUri; } @@ -547,13 +544,11 @@ ContactModel::avatar(const QString& uri) const const QString ContactModel::bestIdForContact(const QString& contactUri) const { - try { - auto contact = getContact(contactUri); + std::lock_guard<std::mutex> lk(pimpl_->contactsMtx_); + if (pimpl_->contacts.contains(contactUri)) { + auto contact = pimpl_->contacts.value(contactUri); return bestIdFromContactInfo(contact); - } catch (const std::out_of_range& e) { - qDebug() << "ContactModel::bestIdForContact" << e.what(); } - return contactUri; }