added a few missing mutexes in prevent searches to be shown when already known

This commit is contained in:
csoler 2018-07-05 10:11:12 +02:00
parent 2067b106e4
commit 47e760a2c5
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
4 changed files with 34 additions and 32 deletions

View File

@ -5109,6 +5109,8 @@ bool RsGxsNetService::locked_stampMsgServerUpdateTS(const RsGxsGroupId& gid)
TurtleRequestId RsGxsNetService::turtleGroupRequest(const RsGxsGroupId& group_id)
{
RS_STACK_MUTEX(mNxsMutex) ;
time_t now = time(NULL);
auto it = mSearchedGroups.find(group_id) ;
@ -5157,6 +5159,7 @@ bool RsGxsNetService::retrieveDistantSearchResults(TurtleRequestId req,std::map<
}
bool RsGxsNetService::retrieveDistantGroupSummary(const RsGxsGroupId& group_id,RsGxsGroupSummary& gs)
{
RS_STACK_MUTEX(mNxsMutex) ;
for(auto it(mDistantSearchResults.begin());it!=mDistantSearchResults.end();++it)
{
auto it2 = it->second.find(group_id) ;

View File

@ -1140,14 +1140,14 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
{
shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL));
std::list<RsGroupMetaData> grp_metas ;
std::map<RsGxsGroupId,RsGroupMetaData> grp_metas ;
channelDialog->getGroupList(grp_metas) ;
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // I dont use a std::map because two or more channels may have the same name.
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
if(IS_GROUP_PUBLISHER((*it).mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).mSubscribeFlags))
grplist.push_back(std::make_pair((*it).mGroupName, (*it).mGroupId));
if(IS_GROUP_PUBLISHER((*it).second.mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags))
grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId));
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;
@ -1164,14 +1164,14 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
{
shareForumMenu.setIcon(QIcon(IMAGE_FORUMS));
std::list<RsGroupMetaData> grp_metas ;
std::map<RsGxsGroupId,RsGroupMetaData> grp_metas ;
forumsDialog->getGroupList(grp_metas) ;
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // I dont use a std::map because two or more channels may have the same name.
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
if(IS_GROUP_SUBSCRIBED((*it).mSubscribeFlags))
grplist.push_back(std::make_pair((*it).mGroupName, (*it).mGroupId));
if(IS_GROUP_SUBSCRIBED((*it).second.mSubscribeFlags))
grplist.push_back(std::make_pair((*it).second.mGroupName, (*it).second.mGroupId));
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;

View File

@ -123,7 +123,7 @@ GxsGroupFrameDialog::~GxsGroupFrameDialog()
delete(ui);
}
void GxsGroupFrameDialog::getGroupList(std::list<RsGroupMetaData>& group_list)
void GxsGroupFrameDialog::getGroupList(std::map<RsGxsGroupId, RsGroupMetaData> &group_list)
{
group_list = mCachedGroupMetas ;
@ -265,8 +265,6 @@ void GxsGroupFrameDialog::updateSearchResults()
auto it2 = mSearchGroupsItems.find(*it);
std::set<RsGxsGroupId>& known_groups(mKnownGroups[*it]) ;
if(mSearchGroupsItems.end() == it2)
{
std::cerr << "GxsGroupFrameDialog::updateSearchResults(): received result notification for req " << std::hex << *it << std::dec << " but no item present!" << std::endl;
@ -276,24 +274,22 @@ void GxsGroupFrameDialog::updateSearchResults()
QList<GroupItemInfo> group_items ;
for(auto it3(group_infos.begin());it3!=group_infos.end();++it3)
if(known_groups.end() == known_groups.find(it3->first))
{
if(mCachedGroupMetas.find(it3->first) == mCachedGroupMetas.end())
{
std::cerr << " adding new group " << it3->first << " " << it3->second.group_id << " \"" << it3->second.group_name << "\"" << std::endl;
known_groups.insert(it3->first) ;
GroupItemInfo i ;
i.id = QString(it3->second.group_id.toStdString().c_str()) ;
i.name = QString::fromUtf8(it3->second.group_name.c_str()) ;
i.description = QString::fromUtf8(it3->second.group_description.c_str()) ;
i.popularity = 0; // could be set to the number of hits
GroupItemInfo i ;
i.id = QString(it3->second.group_id.toStdString().c_str()) ;
i.name = QString::fromUtf8(it3->second.group_name.c_str()) ;
i.description = QString::fromUtf8(it3->second.group_description.c_str()) ;
i.popularity = 0; // could be set to the number of hits
i.lastpost = QDateTime::fromTime_t(it3->second.last_message_ts);
i.subscribeFlags = 0; // irrelevant here
i.publishKey = false ; // IS_GROUP_PUBLISHER(groupInfo.mSubscribeFlags) ;
i.adminKey = false ; // IS_GROUP_ADMIN(groupInfo.mSubscribeFlags) ;
i.max_visible_posts = it3->second.number_of_messages ;
group_items.push_back(i);
group_items.push_back(i);
}
ui->groupTreeWidget->fillGroupItems(it2->second, group_items);
@ -768,7 +764,9 @@ void GxsGroupFrameDialog::changedCurrentGroup(const QString &groupId)
}
// send a request for the group, if it has been distant-searched.
checkRequestGroup(mGroupId) ;
if(mCachedGroupMetas.find(mGroupId) == mCachedGroupMetas.end())
checkRequestGroup(mGroupId) ;
/* search exisiting tab */
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, true);
@ -894,7 +892,7 @@ void GxsGroupFrameDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupI
}
}
void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &groupList, const RsUserdata *userdata)
void GxsGroupFrameDialog::insertGroupsData(const std::map<RsGxsGroupId,RsGroupMetaData> &groupList, const RsUserdata *userdata)
{
if (!mInitialized) {
return;
@ -902,20 +900,18 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &gro
mInFill = true;
std::list<RsGroupMetaData>::const_iterator it;
QList<GroupItemInfo> adminList;
QList<GroupItemInfo> subList;
QList<GroupItemInfo> popList;
QList<GroupItemInfo> otherList;
std::multimap<uint32_t, GroupItemInfo> popMap;
for (it = groupList.begin(); it != groupList.end(); ++it) {
for (auto it = groupList.begin(); it != groupList.end(); ++it) {
/* sort it into Publish (Own), Subscribed, Popular and Other */
uint32_t flags = it->mSubscribeFlags;
uint32_t flags = it->second.mSubscribeFlags;
GroupItemInfo groupItemInfo;
groupInfoToGroupItemInfo(*it, groupItemInfo, userdata);
groupInfoToGroupItemInfo(it->second, groupItemInfo, userdata);
if (IS_GROUP_SUBSCRIBED(flags))
{
@ -932,7 +928,7 @@ void GxsGroupFrameDialog::insertGroupsData(const std::list<RsGroupMetaData> &gro
else
{
//popMap.insert(std::make_pair(it->mPop, groupItemInfo)); /* rate the others by popularity */
popMap.insert(std::make_pair(it->mLastPost, groupItemInfo)); /* rate the others by time of last post */
popMap.insert(std::make_pair(it->second.mLastPost, groupItemInfo)); /* rate the others by time of last post */
}
}
@ -1043,9 +1039,12 @@ void GxsGroupFrameDialog::loadGroupSummary(const uint32_t &token)
RsUserdata *userdata = NULL;
loadGroupSummaryToken(token, groupInfo, userdata);
mCachedGroupMetas = groupInfo ;
mCachedGroupMetas.clear();
for(auto it(groupInfo.begin());it!=groupInfo.end();++it)
mCachedGroupMetas[(*it).mGroupId] = *it;
insertGroupsData(groupInfo, userdata);
insertGroupsData(mCachedGroupMetas, userdata);
updateSearchResults();
mStateHelper->setLoading(TOKEN_TYPE_GROUP_SUMMARY, false);

View File

@ -82,7 +82,7 @@ public:
virtual QString getHelpString() const =0;
virtual void getGroupList(std::list<RsGroupMetaData>& groups) ;
virtual void getGroupList(std::map<RsGxsGroupId,RsGroupMetaData> &groups) ;
protected:
virtual void showEvent(QShowEvent *event);
@ -162,7 +162,7 @@ private:
void processSettings(bool load);
// New Request/Response Loading Functions.
void insertGroupsData(const std::list<RsGroupMetaData> &groupList, const RsUserdata *userdata);
void insertGroupsData(const std::map<RsGxsGroupId, RsGroupMetaData> &groupList, const RsUserdata *userdata);
void requestGroupSummary();
void loadGroupSummary(const uint32_t &token);
@ -209,7 +209,7 @@ private:
/** Qt Designer generated object */
Ui::GxsGroupFrameDialog *ui;
std::list<RsGroupMetaData> mCachedGroupMetas;
std::map<RsGxsGroupId,RsGroupMetaData> mCachedGroupMetas;
std::map<uint32_t,QTreeWidgetItem*> mSearchGroupsItems ;
std::map<uint32_t,std::set<RsGxsGroupId> > mKnownGroups;