removed std::unique_ptr in a few places where it made code far too complicated and less easy to debug

This commit is contained in:
csoler 2020-12-24 00:45:19 +01:00
parent 1ecfbfcd02
commit 41a263eccc
3 changed files with 22 additions and 16 deletions

View File

@ -505,16 +505,16 @@ void IdDialog::updateCircles()
/* This can be big so use a smart pointer to just copy the pointer
* instead of copying the whole list accross the lambdas */
auto circle_metas = std::make_unique<std::list<RsGroupMetaData>>();
auto circle_metas = new std::list<RsGroupMetaData>();
if(!rsGxsCircles->getCirclesSummaries(*circle_metas))
{
RS_ERR("failed to retrieve circles group info list");
delete circle_metas;
return;
}
RsQThreadUtils::postToObject(
[circle_metas = std::move(circle_metas), this]()
RsQThreadUtils::postToObject( [circle_metas, 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
@ -522,6 +522,7 @@ void IdDialog::updateCircles()
loadCircles(*circle_metas);
delete circle_metas;
}, this );
});
@ -1316,17 +1317,19 @@ void IdDialog::updateIdList()
return;
}
auto ids_set = std::make_unique<std::map<RsGxsGroupId,RsGxsIdGroup>>();
auto ids_set = new std::map<RsGxsGroupId,RsGxsIdGroup>();
for(auto it(groups.begin()); it!=groups.end(); ++it)
(*ids_set)[(*it).mMeta.mGroupId] = *it;
RsQThreadUtils::postToObject(
[ids_set = std::move(ids_set), this] ()
RsQThreadUtils::postToObject( [ids_set, 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 */
loadIdentities(*ids_set);
delete ids_set;
}, this );
});

View File

@ -256,17 +256,20 @@ void FriendSelectionWidget::loadIdentities()
return;
}
auto ids = std::make_unique<std::vector<RsGxsGroupId>>();
for(auto& meta: ids_meta) ids->push_back(meta.mGroupId);
auto ids = new std::vector<RsGxsGroupId>();
RsQThreadUtils::postToObject(
[ids = std::move(ids), this]()
for(auto& meta: ids_meta)
ids->push_back(meta.mGroupId);
RsQThreadUtils::postToObject( [ids, this]()
{
// We do that is the GUI thread. Dont try it on another thread!
gxsIds = *ids;
/* TODO: To furter optimize away a copy gxsIds could be a unique_ptr
* too */
fillList();
delete ids;
}, this );
});
}

View File

@ -464,17 +464,16 @@ void GxsTransportStatistics::loadGroups()
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
auto stats = std::make_unique<
std::map<RsGxsGroupId,RsGxsTransGroupStatistics> >();
auto stats = new std::map<RsGxsGroupId,RsGxsTransGroupStatistics>();
if(!rsGxsTrans->getGroupStatistics(*stats))
{
RS_ERR("Cannot retrieve group statistics in GxsTransportStatistics");
delete stats;
return;
}
RsQThreadUtils::postToObject(
[stats = std::move(stats), this]()
RsQThreadUtils::postToObject( [stats, 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
@ -485,6 +484,7 @@ void GxsTransportStatistics::loadGroups()
updateContent();
mStateHelper->setLoading(GXSTRANS_GROUP_META, false);
delete stats;
}, this );
});