From ccd7e08c3f5daa67342136416e0c70f1a7d0394a Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Mon, 28 Jun 2021 22:18:47 -0400 Subject: [PATCH] swarm: fix unhandled exception when invoking the context menu Querying peers should be done the with peersForConversation api. Change-Id: Ia28d19b68e040f7fbd822e0781b3ad8c91186f27 --- src/qrimageprovider.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/qrimageprovider.h b/src/qrimageprovider.h index 2bc39de9a..96c99ffca 100644 --- a/src/qrimageprovider.h +++ b/src/qrimageprovider.h @@ -45,19 +45,25 @@ public: { auto list = id.split('_', Qt::SkipEmptyParts); if (list.size() < 2) - return {QrType::Account, ""}; + return {QrType::Account, {}}; if (list.contains("account") && list.size() > 1) { return {QrType::Account, list[1]}; } else if (list.contains("contact") && list.size() > 1) { - /* - * For contact_xxx, xxx is "" initially - */ - const auto& convInfo = lrcInstance_->getConversationFromConvUid(list[1]); - auto contact = lrcInstance_->getCurrentAccountInfo().contactModel->getContact( - convInfo.participants.at(0)); - return {QrType::Contact, contact.profileInfo.uri}; + // For contact_xxx, xxx is "" initially + try { + const auto& convInfo = lrcInstance_->getConversationFromConvUid(list[1]); + if (convInfo.mode == conversation::Mode::ONE_TO_ONE + || convInfo.mode == conversation::Mode::NON_SWARM) { + auto peerUri = lrcInstance_->getCurrentAccountInfo() + .conversationModel->peersForConversation(convInfo.uid) + .at(0); + return {QrType::Contact, peerUri}; + } + } catch (...) { + } + return {QrType::Contact, {}}; } - return {QrType::Account, ""}; + return {QrType::Account, {}}; } QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize) override -- GitLab