gui(forums): drop the expanded-items save/restore around read-status changes

setMsgReadStatus() only emits dataChanged(); it never resets the model
nor changes its layout, so the expanded items and the current index
survive it untouched. Saving and restoring them on every toggle was
pure overhead, and an expensive one: the restore walks every expanded
item and pays, for each, a linear scan of the post array plus a linear
scan of the view items -- quadratic work on the GUI thread for a single
post marked read or unread on a large forum.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
jolavillette 2026-07-29 12:44:54 +02:00
parent 243c417bfc
commit b0ca91c825

View File

@ -1485,7 +1485,6 @@ void GxsForumThreadWidget::markMsgAsReadUnread (bool read, bool children, bool f
if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) {
return;
}
saveExpandedItems(mSavedExpandedMessages);
QModelIndex src_index;
if(forum)
@ -1497,11 +1496,15 @@ void GxsForumThreadWidget::markMsgAsReadUnread (bool read, bool children, bool f
else
src_index = mThreadModel->getIndexOfMessage(mThreadId);
}
mThreadModel->setMsgReadStatus(src_index,read,children);
//Restore Selection
whileBlocking(ui->threadTreeWidget)->setCurrentIndex(mThreadProxyModel->mapFromSource(mThreadModel->getIndexOfMessage(mThreadId)));
recursRestoreExpandedItems(QModelIndex(),mSavedExpandedMessages);
// setMsgReadStatus() only emits dataChanged(): it never resets the model nor
// changes its layout, so neither the expanded items nor the current index are
// lost here. Saving and restoring them was pure overhead -- and not a cheap
// one: restoring walks every expanded item, and each of them costs a linear
// scan of the post array (getIndexOfMessage) plus a linear scan of the view
// items (QTreeView::setExpanded). On a forum with thousands of posts that is
// quadratic work on the GUI thread for every single post marked read.
mThreadModel->setMsgReadStatus(src_index,read,children);
}
void GxsForumThreadWidget::markMsgAsRead()