added some more debug info and proper error output to GxsDb

This commit is contained in:
csoler 2020-03-26 23:19:34 +01:00
parent 8cf78b072b
commit c18dfb39c3
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
8 changed files with 98 additions and 46 deletions

View file

@ -175,7 +175,7 @@ void GxsGroupFrameDialog::initUi()
void GxsGroupFrameDialog::showEvent(QShowEvent *event)
{
if (!mInitialized || ui->groupTreeWidget->treeWidget()->topLevelItemCount() == 0)
if (!mInitialized )
{
/* Problem: virtual methods cannot be used in constructor */
@ -1028,6 +1028,8 @@ void GxsGroupFrameDialog::updateGroupSummary()
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group info " << std::endl;
return;
}
if(groupInfo.empty())
return;
RsQThreadUtils::postToObject( [this,groupInfo]()
{
@ -1049,17 +1051,18 @@ void GxsGroupFrameDialog::updateGroupSummary()
mNavigatePendingGroupId.clear();
mNavigatePendingMsgId.clear();
}
// update the local cache in order to avoid re-asking the data when the UI wants it (this happens on ::show() for instance)
mCachedGroupMetas.clear();
// update the local cache in order to avoid re-asking the data when the UI wants it (this happens on ::show() for instance)
mCachedGroupMetas.clear();
// now delete the data that is not used anymore
for(auto& g:groupInfo)
{
mCachedGroupMetas[g->mMeta.mGroupId] = g->mMeta;
delete g;
}
for(auto& g:groupInfo)
{
mCachedGroupMetas[g->mMeta.mGroupId] = g->mMeta;
delete g;
}
}, this );
});

View file

@ -1102,6 +1102,19 @@ void GxsForumThreadWidget::insertMessage()
// markMsgAsRead();
}
void GxsForumThreadWidget::setMessageLoadingError(const QString& error)
{
ui->time_label->setText(QString(""));
ui->by_label->setId(RsGxsId());
ui->lineRight->show();
ui->lineLeft->show();
ui->by_text_label->show();
ui->by_label->show();
ui->threadTreeWidget->setFocus();
ui->postText->setText(error);
}
void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
{
/* As some time has elapsed since request - check that this is still the current msg.
@ -1735,28 +1748,32 @@ void GxsForumThreadWidget::updateGroupData()
else
success = true;
// 2 - sort the messages into a proper hierarchy
RsGxsForumGroup group(groups[0]); // we use a copy to share the object in order to avoid group deletion while we're in the thread.
// 3 - update the model in the UI thread.
RsQThreadUtils::postToObject( [group,success,this]()
if(success)
{
/* Here it goes any code you want to be executed on the Qt Gui
// 2 - sort the messages into a proper hierarchy
RsGxsForumGroup group(groups[0]); // we use a copy to share the object in order to avoid group deletion while we're in the thread.
// 3 - update the model in the UI thread.
RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
mForumGroup = group;
mThreadId.clear();
mForumGroup = group;
mThreadId.clear();
ui->threadTreeWidget->setColumnHidden(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, !IS_GROUP_PGP_KNOWN_AUTHED(mForumGroup.mMeta.mSignFlags) && !(IS_GROUP_PGP_AUTHED(mForumGroup.mMeta.mSignFlags)));
ui->subscribeToolButton->setHidden(IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) ;
ui->threadTreeWidget->setColumnHidden(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, !IS_GROUP_PGP_KNOWN_AUTHED(mForumGroup.mMeta.mSignFlags) && !(IS_GROUP_PGP_AUTHED(mForumGroup.mMeta.mSignFlags)));
ui->subscribeToolButton->setHidden(IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) ;
updateForumDescription(success);
}, this );
updateForumDescription(true);
}, this );
}
else
RsQThreadUtils::postToObject( [this]() { updateForumDescription(false); },this);
});
}
@ -1774,17 +1791,18 @@ void GxsForumThreadWidget::updateMessageData(const RsGxsMessageId& msgId)
std::vector<RsGxsForumMsg> msgs;
msgs_to_request.insert(msgId);
QString error_string;
if(!rsGxsForums->getForumContent(groupId(),msgs_to_request,msgs))
{
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve message info for forum " << groupId() << " and MsgId " << msgId << std::endl;
return;
error_string = tr("Failed to retrieve this message. Is the database currently overloaded?");
}
if(msgs.empty())
{
std::cerr << __PRETTY_FUNCTION__ << " no posts for msgId " << msgId << ". Database corruption?" << std::endl;
return;
error_string = tr("No data for this message. Is the database corrupted?");
}
if(msgs.size() > 1)
{
@ -1792,25 +1810,32 @@ void GxsForumThreadWidget::updateMessageData(const RsGxsMessageId& msgId)
std::cerr << "Messages are:" << std::endl;
for(auto it(msgs.begin());it!=msgs.end();++it)
std::cerr << (*it).mMeta << std::endl;
error_string = tr("More than one entry for this message. Is the database corrupted?");
}
// 2 - sort the messages into a proper hierarchy
RsGxsForumMsg msg(msgs[0]);
// 3 - update the model in the UI thread.
RsQThreadUtils::postToObject( [msg,this]()
if(error_string.isNull())
{
/* Here it goes any code you want to be executed on the Qt Gui
// 2 - sort the messages into a proper hierarchy
RsGxsForumMsg msg(msgs[0]);
// 3 - update the model in the UI thread.
RsQThreadUtils::postToObject( [msg,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
insertMessageData(msg);
insertMessageData(msg);
ui->threadTreeWidget->setColumnHidden(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, !IS_GROUP_PGP_KNOWN_AUTHED(mForumGroup.mMeta.mSignFlags) && !(IS_GROUP_PGP_AUTHED(mForumGroup.mMeta.mSignFlags)));
ui->subscribeToolButton->setHidden(IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) ;
}, this );
ui->threadTreeWidget->setColumnHidden(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION, !IS_GROUP_PGP_KNOWN_AUTHED(mForumGroup.mMeta.mSignFlags) && !(IS_GROUP_PGP_AUTHED(mForumGroup.mMeta.mSignFlags)));
ui->subscribeToolButton->setHidden(IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) ;
}, this );
}
else
RsQThreadUtils::postToObject( [error_string,this](){ setMessageLoadingError(error_string); } );
});
}

View file

@ -92,6 +92,7 @@ protected:
/* GxsMessageFrameWidget */
virtual void setAllMessagesReadDo(bool read, uint32_t &token);
void setMessageLoadingError(const QString& error);
private slots:
/** Create the context popup menu and it's submenus */
void threadListCustomPopupMenu(QPoint point);