From 1ecfbfcd02c0e5f54e1d3811e7fd8f228b814879 Mon Sep 17 00:00:00 2001
From: csoler <csoler@users.sourceforge.net>
Date: Thu, 24 Dec 2020 00:34:49 +0100
Subject: [PATCH] fixed bug in circles edit dialog

---
 .../src/gui/Circles/CreateCircleDialog.cpp        | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp
index a0eacd060..cf346aaf9 100644
--- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp
+++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp
@@ -707,23 +707,30 @@ void CreateCircleDialog::loadIdentities()
 		}
 
 		std::set<RsGxsId> ids;
-		for(auto& meta:ids_meta) ids.insert(RsGxsId(meta.mGroupId));
+        for(auto& meta:ids_meta)
+            ids.insert(RsGxsId(meta.mGroupId));
+
+        // Needs a pointer on the heap, to pass to postToObject, otherwise it will get deleted before
+        // the posted method will actually run. Memory ownership is left to the posted method.
+
+        auto id_groups = new std::vector<RsGxsIdGroup>();
 
-		auto id_groups = std::make_unique<std::vector<RsGxsIdGroup>>();
 		if(!rsIdentity->getIdentitiesInfo(ids, *id_groups))
 		{
 			RS_ERR("failed to retrieve identities group info for all identities");
+            delete id_groups;
 			return;
 		}
 
-		RsQThreadUtils::postToObject(
-		            [id_groups = std::move(id_groups), this]()
+        RsQThreadUtils::postToObject( [id_groups, 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 */
 
 			fillIdentitiesList(*id_groups);
+
+            delete id_groups;
 		}, this );
 	});