trying new notification system using begin/end remove/insert rows to avoid crash

This commit is contained in:
csoler 2018-12-04 23:10:24 +01:00
parent b63544e856
commit 6fae40d417
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C

View File

@ -53,13 +53,12 @@ RsGxsForumModel::RsGxsForumModel(QObject *parent)
void RsGxsForumModel::preMods() void RsGxsForumModel::preMods()
{ {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
beginResetModel();
} }
void RsGxsForumModel::postMods() void RsGxsForumModel::postMods()
{ {
endResetModel(); //emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount(QModelIndex())-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL)); emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
emit layoutChanged(); //emit layoutChanged();
} }
void RsGxsForumModel::setTreeMode(TreeMode mode) void RsGxsForumModel::setTreeMode(TreeMode mode)
@ -695,6 +694,9 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
{ {
preMods(); preMods();
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
endRemoveRows();
mForumGroup = group; mForumGroup = group;
mPosts = posts; mPosts = posts;
mPostVersions = post_versions; mPostVersions = post_versions;
@ -716,6 +718,8 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
debug_dump(); debug_dump();
#endif #endif
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
endInsertRows();
postMods(); postMods();
emit forumLoaded(); emit forumLoaded();
} }