From 1cf689a6ad9d6c5cd29e11a6a96cb075eb2bbbb8 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 27 Mar 2022 22:11:07 +0200 Subject: Replaced ThreadSync with stl's mutex --- Stars45/CmpSelectDlg.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'Stars45/CmpSelectDlg.cpp') diff --git a/Stars45/CmpSelectDlg.cpp b/Stars45/CmpSelectDlg.cpp index 18ba3d0..95f9efa 100644 --- a/Stars45/CmpSelectDlg.cpp +++ b/Stars45/CmpSelectDlg.cpp @@ -11,6 +11,8 @@ Mission Select Dialog Active Window class */ +#include + #include "CmpSelectDlg.h" #include "ConfirmDlg.h" #include "MenuScreen.h" @@ -32,7 +34,6 @@ #include "Mouse.h" #include "ParseUtil.h" #include "FormatUtil.h" -#include "ThreadSync.h" // +--------------------------------------------------------------------+ // DECLARE MAPPING FUNCTIONS: @@ -118,7 +119,7 @@ CmpSelectDlg::ExecFrame() OnAccept(0); } - AutoThreadSync a(sync); + const std::lock_guard lock(sync); if (loaded) { loaded = false; @@ -197,7 +198,7 @@ CmpSelectDlg::ExecFrame() bool CmpSelectDlg::CanClose() { - AutoThreadSync a(sync); + const std::lock_guard lock(sync); return !loading; } @@ -206,7 +207,7 @@ CmpSelectDlg::CanClose() void CmpSelectDlg::ShowNewCampaigns() { - AutoThreadSync a(sync); + const std::lock_guard lock(sync); if (loading && description) { description->SetText(ContentBundle::GetInstance()->GetText("CmpSelectDlg.already-loading")); @@ -283,7 +284,7 @@ CmpSelectDlg::ShowNewCampaigns() void CmpSelectDlg::ShowSavedCampaigns() { - AutoThreadSync a(sync); + const std::lock_guard lock(sync); if (loading && description) { description->SetText(ContentBundle::GetInstance()->GetText("CmpSelectDlg.already-loading")); @@ -332,7 +333,7 @@ void CmpSelectDlg::OnCampaignSelect(AWEvent* event) { if (description && lst_campaigns) { - AutoThreadSync a(sync); + const std::lock_guard lock(sync); if (loading) { description->SetText(ContentBundle::GetInstance()->GetText("CmpSelectDlg.already-loading")); @@ -363,7 +364,7 @@ CmpSelectDlg::OnCampaignSelect(AWEvent* event) images[i]->CopyBitmap(*c->GetImage(1)); lst_campaigns->SetItemImage(i, images[i]); - AutoThreadSync a(sync); + const std::lock_guard lock(sync); load_index = i; } else { @@ -486,7 +487,7 @@ CmpSelectDlg::OnConfirmDelete(AWEvent* event) void CmpSelectDlg::OnAccept(AWEvent* event) { - AutoThreadSync a(sync); + const std::lock_guard lock(sync); if (loading) return; @@ -594,13 +595,13 @@ CmpSelectDlg::LoadProc() c = savegame.GetCampaign(); } - sync.acquire(); + sync.lock(); loading = false; loaded = true; campaign = c; - sync.release(); + sync.unlock(); return 0; } -- cgit v1.1