From 2f6f2bab05622c2f773a5eb30456c74ea56b3c0a Mon Sep 17 00:00:00 2001 From: Jan Hambrecht Date: Wed, 27 Feb 2019 21:16:54 +0100 Subject: [PATCH] fix crash when mapping unified mailboxes to collections Summary: when the fetched unified mailbox collections and loaded mailboxes differ then trying to get a loaded mailbox using the collection name may fail. wrapping the call in a try-catch block fixes the crash Reviewers: dvratil, mlaurent Reviewed By: mlaurent Subscribers: kde-pim Tags: #kde_pim Differential Revision: https://phabricator.kde.org/D19323 --- agents/unifiedmailboxagent/unifiedmailboxmanager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agents/unifiedmailboxagent/unifiedmailboxmanager.cpp b/agents/unifiedmailboxagent/unifiedmailboxmanager.cpp index cb9525b3b..fd7af4a61 100644 --- a/agents/unifiedmailboxagent/unifiedmailboxmanager.cpp +++ b/agents/unifiedmailboxagent/unifiedmailboxmanager.cpp @@ -388,8 +388,12 @@ void UnifiedMailboxManager::discoverBoxCollections(FinishedCallback &&finishedCb if (!isUnifiedMailbox(col) || col.parentCollection() == Akonadi::Collection::root()) { continue; } - - mMailboxes.at(col.name())->setCollectionId(col.id()); + const auto it = mMailboxes.find(col.name()); + if (it == mMailboxes.end()) { + qCWarning(UNIFIEDMAILBOXAGENT_LOG) << "Failed to find an unified mailbox for source collection" << col.id(); + } else { + it->second->setCollectionId(col.id()); + } } }); if (finishedCb) {