From 3f04244169fa73c45fac1b8d003d032b53b7d685 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 17 Feb 2021 21:41:38 +0100 Subject: [PATCH] added guarding code against close for circle loading too --- .../src/gui/Circles/CreateCircleDialog.cpp | 26 ++++++++++++++----- .../src/gui/Circles/CreateCircleDialog.h | 3 ++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp index 417dfc011..c743e4b19 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp @@ -52,7 +52,8 @@ CreateCircleDialog::CreateCircleDialog() : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint) { mIdentitiesLoading = false; - mCloseAfterIdentitiesLoaded = false; + mCircleLoading = false; + mCloseRequested = false; /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -123,10 +124,10 @@ CreateCircleDialog::~CreateCircleDialog() } void CreateCircleDialog::closeEvent(QCloseEvent *e) { - if(mIdentitiesLoading) + if(mIdentitiesLoading || mCircleLoading) { - std::cerr << "Close() called. Identities currently loading => not actually closing." << std::endl; - mCloseAfterIdentitiesLoaded = true; + std::cerr << "Close() called. Identities or circle currently loading => not actually closing." << std::endl; + mCloseRequested = true; return; } else @@ -684,6 +685,9 @@ void CreateCircleDialog::loadCircle(const RsGxsGroupId& groupId) QTreeWidget *tree = ui.treeWidget_membership; if (mClearList) tree->clear(); + std::cerr << "Loading circle..."<< std::endl; + mCircleLoading = true; + RsThread::async([groupId,this]() { std::vector circlesInfo ; @@ -709,7 +713,17 @@ void CreateCircleDialog::loadCircle(const RsGxsGroupId& groupId) #endif updateCircleGUI(); - }, this ); + mCircleLoading = false; + + std::cerr << "finished loading circle..."<< std::endl; + + if(mCloseRequested && !mIdentitiesLoading) + { + std::cerr << "Close() previously called, so closing now." << std::endl; + close(); + } + + }, this ); }); } @@ -759,7 +773,7 @@ void CreateCircleDialog::loadIdentities() std::cerr << "Identities finished loading." << std::endl; mIdentitiesLoading = false; - if(mCloseAfterIdentitiesLoaded) + if(mCloseRequested && !mCircleLoading) { std::cerr << "Close() previously called, so closing now." << std::endl; close(); diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.h b/retroshare-gui/src/gui/Circles/CreateCircleDialog.h index b931c0f32..33fd3537b 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.h +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.h @@ -75,7 +75,8 @@ private: bool mIsExternalCircle; bool mReadOnly; bool mIdentitiesLoading; - bool mCloseAfterIdentitiesLoaded; + bool mCircleLoading; + bool mCloseRequested; void loadCircle(const RsGxsGroupId& groupId); void loadIdentities();