From c34607b4d763ba13a05b84363fbd8a4c0fa43f39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Wed, 3 Nov 2021 15:22:26 -0400
Subject: [PATCH] callbackshandler: get exceptions from getAccountInfo

As the account can be destroyed while a signal is treated

Change-Id: I16201dc917a14184f57ba15f0e6c1ddd4b1f5311
---
 src/callbackshandler.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/callbackshandler.cpp b/src/callbackshandler.cpp
index b0ba534f..84397697 100644
--- a/src/callbackshandler.cpp
+++ b/src/callbackshandler.cpp
@@ -569,9 +569,13 @@ CallbacksHandler::slotDataTransferEvent(const QString& accountId,
 
     api::datatransfer::Info info;
     if (conversationId.isEmpty()) {
-        parent.getAccountModel().getAccountInfo(accountId).dataTransferModel->transferInfo(accountId,
-                                                                                           fileId,
-                                                                                           info);
+        try {
+            parent.getAccountModel()
+                .getAccountInfo(accountId)
+                .dataTransferModel->transferInfo(accountId, fileId, info);
+        } catch (...) {
+            return;
+        }
     } else {
         info.uid = fileId;
         info.status = convertDataTransferEvent(event);
@@ -579,8 +583,12 @@ CallbacksHandler::slotDataTransferEvent(const QString& accountId,
         info.accountId = accountId;
         qlonglong totalSize, progress;
         QString path;
-        parent.getAccountModel().getAccountInfo(accountId).dataTransferModel->fileTransferInfo(
-            accountId, conversationId, fileId, path, totalSize, progress);
+        try {
+            parent.getAccountModel().getAccountInfo(accountId).dataTransferModel->fileTransferInfo(
+                accountId, conversationId, fileId, path, totalSize, progress);
+        } catch (...) {
+            return;
+        }
         auto fi = QFileInfo(path);
         if (fi.isSymLink()) {
             path = fi.symLinkTarget();
-- 
GitLab