From 79ce60382ac6cf26a1a57401d9a898b39db9c457 Mon Sep 17 00:00:00 2001 From: Nicolas Werner <nicolas.werner@hotmail.de> Date: Sat, 24 Sep 2022 10:36:26 +0200 Subject: [PATCH] Fix crash when deleting room summary Since this is used across different threads, we have to delete it on the event loop. Thank you, q234rty, for the help with debugging this. --- src/timeline/InputBar.h | 17 +++++++++-------- src/timeline/TimelineModel.h | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index 816d4e37f..8590d84fb 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -25,6 +25,15 @@ class CombinedImagePackModel; class QMimeData; class QDropEvent; +struct DeleteLaterDeleter +{ + void operator()(QObject *p) + { + if (p) + p->deleteLater(); + } +}; + enum class MarkdownOverride { NOT_SPECIFIED, // no override set @@ -278,14 +287,6 @@ private: bool uploading_ = false; bool containsAtRoom_ = false; - struct DeleteLaterDeleter - { - void operator()(QObject *p) - { - if (p) - p->deleteLater(); - } - }; using UploadHandle = std::unique_ptr<MediaUpload, DeleteLaterDeleter>; std::vector<UploadHandle> unconfirmedUploads; std::vector<UploadHandle> runningUploads; diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index ea6daa343..a098f1bd5 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -493,8 +493,8 @@ private: std::string last_event_id; std::string fullyReadEventId_; - std::unique_ptr<RoomSummary> parentSummary = nullptr; - bool parentChecked = false; + std::unique_ptr<RoomSummary, DeleteLaterDeleter> parentSummary = nullptr; + bool parentChecked = false; }; template<class T> -- GitLab