1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-27 21:49:10 +02:00

Removed optional locking in waitWhileDialog method

This commit is contained in:
Ivan Savenko 2023-09-27 18:44:08 +03:00
parent d6b9fa8fbd
commit 0dcfd6e65c
3 changed files with 9 additions and 8 deletions

View File

@ -1331,7 +1331,7 @@ void CPlayerInterface::showRecruitmentDialog(const CGDwelling *dwelling, const C
GH.windows().createAndPushWindow<CRecruitmentWindow>(dwelling, level, dst, recruitCb); GH.windows().createAndPushWindow<CRecruitmentWindow>(dwelling, level, dst, recruitCb);
} }
void CPlayerInterface::waitWhileDialog(bool unlockPim) void CPlayerInterface::waitWhileDialog()
{ {
if (GH.amIGuiThread()) if (GH.amIGuiThread())
{ {
@ -1339,7 +1339,7 @@ void CPlayerInterface::waitWhileDialog(bool unlockPim)
return; return;
} }
auto unlock = vstd::makeUnlockGuardIf(GH.interfaceMutex, unlockPim); auto unlock = vstd::makeUnlockGuard(GH.interfaceMutex);
boost::unique_lock<boost::mutex> un(showingDialog->mx); boost::unique_lock<boost::mutex> un(showingDialog->mx);
while(showingDialog->data) while(showingDialog->data)
showingDialog->cond.wait(un); showingDialog->cond.wait(un);
@ -1811,14 +1811,14 @@ void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
artWin->artifactDisassembled(al); artWin->artifactDisassembled(al);
} }
void CPlayerInterface::waitForAllDialogs(bool unlockPim) void CPlayerInterface::waitForAllDialogs()
{ {
while(!dialogs.empty()) while(!dialogs.empty())
{ {
auto unlock = vstd::makeUnlockGuardIf(GH.interfaceMutex, unlockPim); auto unlock = vstd::makeUnlockGuard(GH.interfaceMutex);
boost::this_thread::sleep_for(boost::chrono::milliseconds(5)); boost::this_thread::sleep_for(boost::chrono::milliseconds(5));
} }
waitWhileDialog(unlockPim); waitWhileDialog();
} }
void CPlayerInterface::proposeLoadingGame() void CPlayerInterface::proposeLoadingGame()

View File

@ -184,8 +184,8 @@ public: // public interface for use by client via LOCPLINT access
void showHeroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2); void showHeroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2);
void showArtifactAssemblyDialog(const Artifact * artifact, const Artifact * assembledArtifact, CFunctionList<void()> onYes); void showArtifactAssemblyDialog(const Artifact * artifact, const Artifact * assembledArtifact, CFunctionList<void()> onYes);
void waitWhileDialog(bool unlockPim = true); void waitWhileDialog();
void waitForAllDialogs(bool unlockPim = true); void waitForAllDialogs();
void openTownWindow(const CGTownInstance * town); //shows townscreen void openTownWindow(const CGTownInstance * town); //shows townscreen
void openHeroWindow(const CGHeroInstance * hero); //shows hero window with given hero void openHeroWindow(const CGHeroInstance * hero); //shows hero window with given hero

View File

@ -287,6 +287,7 @@ bool ArtifactUtilsClient::askToAssemble(const CGHeroInstance * hero, const Artif
{ {
auto askThread = new boost::thread([hero, art, slot, assemblyPossibilities]() -> void auto askThread = new boost::thread([hero, art, slot, assemblyPossibilities]() -> void
{ {
boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
for(const auto combinedArt : assemblyPossibilities) for(const auto combinedArt : assemblyPossibilities)
{ {
bool assembleConfirmed = false; bool assembleConfirmed = false;
@ -294,7 +295,7 @@ bool ArtifactUtilsClient::askToAssemble(const CGHeroInstance * hero, const Artif
onYesHandlers += std::bind(&CCallback::assembleArtifacts, LOCPLINT->cb.get(), hero, slot, true, combinedArt->getId()); onYesHandlers += std::bind(&CCallback::assembleArtifacts, LOCPLINT->cb.get(), hero, slot, true, combinedArt->getId());
LOCPLINT->showArtifactAssemblyDialog(art->artType, combinedArt, onYesHandlers); LOCPLINT->showArtifactAssemblyDialog(art->artType, combinedArt, onYesHandlers);
LOCPLINT->waitWhileDialog(false); LOCPLINT->waitWhileDialog();
if(assembleConfirmed) if(assembleConfirmed)
break; break;
} }