From af0161054f4b2193d54108d5d9989d3100010ea7 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 14 Oct 2019 22:24:36 +0200 Subject: [PATCH] fixed shifting bug in forums when setting a post as read, caused by wrong calculation of parent index --- .../src/gui/gxsforums/GxsForumModel.cpp | 41 +++++++++++++++---- .../gui/gxsforums/GxsForumThreadWidget.cpp | 14 ------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index dd2c87e74..851f6fd16 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -281,12 +281,22 @@ void *RsGxsForumModel::getParentRef(void *ref,int& row) const { ForumModelIndex ref_entry; - if(mTreeMode == TREE_MODE_FLAT) - return NULL; - if(!convertRefPointerToTabEntry(ref,ref_entry) || ref_entry >= mPosts.size()) return NULL ; + if(mTreeMode == TREE_MODE_FLAT) + { + if(ref_entry == 0) + { + RsErr() << "getParentRef() shouldn't be asked for the parent of NULL" << std::endl; + row = 0; + } + else + row = ref_entry-1; + + return NULL; + } + ForumModelIndex parent_entry = mPosts[ref_entry].mParent; if(parent_entry == 0) // top level index @@ -726,7 +736,11 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vectorsecond.size();++i) if(it->second[i].second == mid) + { postId = it->first; + break; + } - for(uint32_t i=0;i