From 807232ffa5ec7e64632772edcbf1c61a44bc8c0a Mon Sep 17 00:00:00 2001 From: thunder2 Date: Thu, 4 Aug 2022 12:48:44 +0200 Subject: [PATCH] Fixed crash when closing forum message item in activity stream with set as read and remove --- retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp | 16 +++++++++------- retroshare-gui/src/gui/feeds/GxsForumMsgItem.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index 8bf4899f1..556dd1108 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -411,7 +411,7 @@ void GxsForumMsgItem::doExpand(bool open) ui->parentFrame->show(); } - setAsRead(); + setAsRead(true); } else { @@ -459,7 +459,7 @@ void GxsForumMsgItem::readAndClearItem() std::cerr << std::endl; #endif - setAsRead(); + setAsRead(false); removeItem(); } @@ -473,7 +473,7 @@ void GxsForumMsgItem::unsubscribeForum() unsubscribe(); } -void GxsForumMsgItem::setAsRead() +void GxsForumMsgItem::setAsRead(bool doUpdate) { if (mInFill) { return; @@ -481,14 +481,16 @@ void GxsForumMsgItem::setAsRead() mCloseOnRead = false; - RsThread::async( [this]() { + RsThread::async( [this, doUpdate]() { RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); rsGxsForums->markRead(msgPair, true); - RsQThreadUtils::postToObject( [this]() { - setReadStatus(false, true); - } ); + if (doUpdate) { + RsQThreadUtils::postToObject( [this]() { + setReadStatus(false, true); + } ); + } }); } diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h index 17287ada1..34166ee59 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h @@ -82,7 +82,7 @@ private: void fillParentMessage(); void fillExpandFrame(); void setReadStatus(bool isNew, bool isUnread); - void setAsRead(); + void setAsRead(bool doUpdate); private: bool mInFill;