added guarding code against close for circle loading too

This commit is contained in:
csoler 2021-02-17 21:41:38 +01:00
parent 3548f5eac5
commit 3f04244169
2 changed files with 22 additions and 7 deletions

View file

@ -52,7 +52,8 @@ CreateCircleDialog::CreateCircleDialog()
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint) : QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
{ {
mIdentitiesLoading = false; mIdentitiesLoading = false;
mCloseAfterIdentitiesLoaded = false; mCircleLoading = false;
mCloseRequested = false;
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -123,10 +124,10 @@ CreateCircleDialog::~CreateCircleDialog()
} }
void CreateCircleDialog::closeEvent(QCloseEvent *e) void CreateCircleDialog::closeEvent(QCloseEvent *e)
{ {
if(mIdentitiesLoading) if(mIdentitiesLoading || mCircleLoading)
{ {
std::cerr << "Close() called. Identities currently loading => not actually closing." << std::endl; std::cerr << "Close() called. Identities or circle currently loading => not actually closing." << std::endl;
mCloseAfterIdentitiesLoaded = true; mCloseRequested = true;
return; return;
} }
else else
@ -684,6 +685,9 @@ void CreateCircleDialog::loadCircle(const RsGxsGroupId& groupId)
QTreeWidget *tree = ui.treeWidget_membership; QTreeWidget *tree = ui.treeWidget_membership;
if (mClearList) tree->clear(); if (mClearList) tree->clear();
std::cerr << "Loading circle..."<< std::endl;
mCircleLoading = true;
RsThread::async([groupId,this]() RsThread::async([groupId,this]()
{ {
std::vector<RsGxsCircleGroup> circlesInfo ; std::vector<RsGxsCircleGroup> circlesInfo ;
@ -709,7 +713,17 @@ void CreateCircleDialog::loadCircle(const RsGxsGroupId& groupId)
#endif #endif
updateCircleGUI(); 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; std::cerr << "Identities finished loading." << std::endl;
mIdentitiesLoading = false; mIdentitiesLoading = false;
if(mCloseAfterIdentitiesLoaded) if(mCloseRequested && !mCircleLoading)
{ {
std::cerr << "Close() previously called, so closing now." << std::endl; std::cerr << "Close() previously called, so closing now." << std::endl;
close(); close();

View file

@ -75,7 +75,8 @@ private:
bool mIsExternalCircle; bool mIsExternalCircle;
bool mReadOnly; bool mReadOnly;
bool mIdentitiesLoading; bool mIdentitiesLoading;
bool mCloseAfterIdentitiesLoaded; bool mCircleLoading;
bool mCloseRequested;
void loadCircle(const RsGxsGroupId& groupId); void loadCircle(const RsGxsGroupId& groupId);
void loadIdentities(); void loadIdentities();