From 41a263eccca1618bec6ec8d0e331aed18359ce05 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 24 Dec 2020 00:45:19 +0100 Subject: [PATCH] removed std::unique_ptr in a few places where it made code far too complicated and less easy to debug --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 17 ++++++++++------- .../src/gui/common/FriendSelectionWidget.cpp | 11 +++++++---- .../gui/statistics/GxsTransportStatistics.cpp | 10 +++++----- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index e42dfeb26..bffed9508 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -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>(); + auto circle_metas = new std::list(); 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,7 +522,8 @@ void IdDialog::updateCircles() loadCircles(*circle_metas); - }, this ); + delete circle_metas; + }, this ); }); } @@ -1316,17 +1317,19 @@ void IdDialog::updateIdList() return; } - auto ids_set = std::make_unique>(); + auto ids_set = new std::map(); + 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 ); }); diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index bb5e693ba..a2b355e06 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -256,17 +256,20 @@ void FriendSelectionWidget::loadIdentities() return; } - auto ids = std::make_unique>(); - for(auto& meta: ids_meta) ids->push_back(meta.mGroupId); + auto ids = new std::vector(); - 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 ); }); } diff --git a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp index c258cb4bc..5b8fb8e5d 100644 --- a/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GxsTransportStatistics.cpp @@ -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 >(); + auto stats = new std::map(); 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,7 +484,8 @@ void GxsTransportStatistics::loadGroups() updateContent(); mStateHelper->setLoading(GXSTRANS_GROUP_META, false); - }, this ); + delete stats; + }, this ); }); }