mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
attempt to fix crash when threads collide in forum model
This commit is contained in:
parent
ec0bb5347e
commit
fb962c4b5b
@ -49,39 +49,46 @@ RsGxsForumModel::RsGxsForumModel(QObject *parent)
|
||||
mFilteringEnabled=false;
|
||||
}
|
||||
|
||||
void RsGxsForumModel::preMods()
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
beginResetModel();
|
||||
}
|
||||
void RsGxsForumModel::postMods()
|
||||
{
|
||||
endResetModel();
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::setTreeMode(TreeMode mode)
|
||||
{
|
||||
if(mode == mTreeMode)
|
||||
return;
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
preMods();
|
||||
mTreeMode = mode;
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::setSortMode(SortMode mode)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
preMods();
|
||||
|
||||
mSortMode = mode;
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::initEmptyHierarchy(std::vector<ForumModelPostEntry>& posts)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
preMods();
|
||||
|
||||
posts.resize(1); // adds a sentinel item
|
||||
posts[0].mTitle = "Root sentinel post" ;
|
||||
posts[0].mParent = 0;
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
postMods();
|
||||
}
|
||||
|
||||
int RsGxsForumModel::rowCount(const QModelIndex& parent) const
|
||||
@ -474,7 +481,7 @@ uint32_t RsGxsForumModel::recursUpdateFilterStatus(ForumModelIndex i,int column,
|
||||
|
||||
void RsGxsForumModel::setFilter(int column,const QStringList& strings,uint32_t& count)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
preMods();
|
||||
|
||||
if(!strings.empty())
|
||||
{
|
||||
@ -484,8 +491,7 @@ void RsGxsForumModel::setFilter(int column,const QStringList& strings,uint32_t&
|
||||
else
|
||||
mFilteringEnabled = false;
|
||||
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
emit layoutChanged();
|
||||
postMods();
|
||||
}
|
||||
|
||||
QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry& fmpe,int column) const
|
||||
@ -672,19 +678,18 @@ void RsGxsForumModel::setForum(const RsGxsGroupId& forum_group_id)
|
||||
|
||||
void RsGxsForumModel::clear()
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
preMods();
|
||||
|
||||
mPosts.clear();
|
||||
mPostVersions.clear();
|
||||
|
||||
emit layoutChanged();
|
||||
postMods();
|
||||
emit forumLoaded();
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
}
|
||||
|
||||
void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<ForumModelPostEntry>& posts,const std::map<RsGxsMessageId,std::vector<std::pair<time_t,RsGxsMessageId> > >& post_versions)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
preMods();
|
||||
|
||||
mForumGroup = group;
|
||||
mPosts = posts;
|
||||
@ -707,9 +712,8 @@ void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<F
|
||||
debug_dump();
|
||||
#endif
|
||||
|
||||
emit layoutChanged();
|
||||
postMods();
|
||||
emit forumLoaded();
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
}
|
||||
|
||||
void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
|
||||
@ -1139,7 +1143,7 @@ void RsGxsForumModel::setMsgReadStatus(const QModelIndex& i,bool read_status,boo
|
||||
if(!i.isValid())
|
||||
return ;
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
preMods();
|
||||
|
||||
void *ref = i.internalPointer();
|
||||
uint32_t entry = 0;
|
||||
@ -1151,8 +1155,7 @@ void RsGxsForumModel::setMsgReadStatus(const QModelIndex& i,bool read_status,boo
|
||||
recursSetMsgReadStatus(entry,read_status,with_children) ;
|
||||
recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below);
|
||||
|
||||
emit layoutChanged();
|
||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(0,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
|
||||
postMods();
|
||||
}
|
||||
|
||||
void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status,bool with_children)
|
||||
|
@ -165,6 +165,9 @@ private:
|
||||
TreeMode mTreeMode;
|
||||
SortMode mSortMode;
|
||||
|
||||
void preMods() ;
|
||||
void postMods() ;
|
||||
|
||||
void *getParentRef(void *ref,int& row) const;
|
||||
void *getChildRef(void *ref,int row) const;
|
||||
//bool hasIndex(int row,int column,const QModelIndex& parent)const;
|
||||
|
@ -305,6 +305,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||
setUpdateWhenInvisible(true);
|
||||
|
||||
mSubscribeFlags = 0;
|
||||
mUpdating = false;
|
||||
mSignFlags = 0;
|
||||
mUnreadCount = 0;
|
||||
mNewCount = 0;
|
||||
@ -583,8 +584,12 @@ static void removeMessages(std::map<RsGxsGroupId, std::set<RsGxsMessageId> > &ms
|
||||
|
||||
void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||
{
|
||||
if(mUpdating)
|
||||
return;
|
||||
|
||||
if (complete) {
|
||||
/* Fill complete */
|
||||
mUpdating=true;
|
||||
updateGroupData();
|
||||
mThreadModel->setForum(groupId());
|
||||
insertMessage();
|
||||
@ -604,6 +609,7 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||
if (grpIds.find(groupId())!=grpIds.end()){
|
||||
updateGroup = true;
|
||||
/* Update threads */
|
||||
mUpdating=true;
|
||||
mThreadModel->setForum(groupId());
|
||||
} else {
|
||||
std::map<RsGxsGroupId, std::set<RsGxsMessageId> > msgIds;
|
||||
@ -615,7 +621,10 @@ void GxsForumThreadWidget::updateDisplay(bool complete)
|
||||
}
|
||||
|
||||
if (msgIds.find(groupId()) != msgIds.end())
|
||||
{
|
||||
mUpdating=true;
|
||||
mThreadModel->setForum(groupId()); /* Update threads */
|
||||
}
|
||||
}
|
||||
|
||||
if (updateGroup) {
|
||||
@ -855,6 +864,9 @@ void GxsForumThreadWidget::togglethreadview_internal()
|
||||
|
||||
void GxsForumThreadWidget::changedVersion()
|
||||
{
|
||||
if(mUpdating)
|
||||
return;
|
||||
|
||||
mThreadId = RsGxsMessageId(ui->versions_CB->itemData(ui->versions_CB->currentIndex()).toString().toStdString()) ;
|
||||
|
||||
ui->postText->resetImagesStatus(Settings->getForumLoadEmbeddedImages()) ;
|
||||
@ -863,6 +875,9 @@ void GxsForumThreadWidget::changedVersion()
|
||||
|
||||
void GxsForumThreadWidget::changedThread(QModelIndex index)
|
||||
{
|
||||
if(mUpdating)
|
||||
return;
|
||||
|
||||
if(!index.isValid())
|
||||
{
|
||||
mThreadId.clear();
|
||||
@ -884,6 +899,9 @@ void GxsForumThreadWidget::changedThread(QModelIndex index)
|
||||
|
||||
void GxsForumThreadWidget::clickedThread(QModelIndex index)
|
||||
{
|
||||
if(mUpdating)
|
||||
return;
|
||||
|
||||
if(!index.isValid())
|
||||
return;
|
||||
|
||||
@ -1622,6 +1640,8 @@ void GxsForumThreadWidget::updateGroupName()
|
||||
ui->forumName->setText(QString::fromUtf8(mForumGroup.mMeta.mGroupName.c_str()));
|
||||
ui->threadTreeWidget->sortByColumn(RsGxsForumModel::COLUMN_THREAD_DATE, Qt::DescendingOrder);
|
||||
ui->threadTreeWidget->update();
|
||||
|
||||
mUpdating = false;
|
||||
}
|
||||
void GxsForumThreadWidget::updateGroupData()
|
||||
{
|
||||
|
@ -176,6 +176,7 @@ private:
|
||||
QString mForumDescription;
|
||||
int mSubscribeFlags;
|
||||
int mSignFlags;
|
||||
bool mUpdating;
|
||||
bool mInProcessSettings;
|
||||
bool mInMsgAsReadUnread;
|
||||
int mLastViewType;
|
||||
|
Loading…
Reference in New Issue
Block a user