summaryrefslogtreecommitdiffhomepage
path: root/Stars45/CmpSelectDlg.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-27 22:11:07 +0200
committerAki <please@ignore.pl>2022-03-27 22:11:07 +0200
commit1cf689a6ad9d6c5cd29e11a6a96cb075eb2bbbb8 (patch)
tree3b31cdfcefe051a9a31972703b4d738812467abf /Stars45/CmpSelectDlg.cpp
parent2ba515370864b85bd29b0d23083248c74a868691 (diff)
downloadstarshatter-1cf689a6ad9d6c5cd29e11a6a96cb075eb2bbbb8.zip
starshatter-1cf689a6ad9d6c5cd29e11a6a96cb075eb2bbbb8.tar.gz
starshatter-1cf689a6ad9d6c5cd29e11a6a96cb075eb2bbbb8.tar.bz2
Replaced ThreadSync with stl's mutex
Diffstat (limited to 'Stars45/CmpSelectDlg.cpp')
-rw-r--r--Stars45/CmpSelectDlg.cpp21
1 files changed, 11 insertions, 10 deletions
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 <mutex>
+
#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<std::mutex> lock(sync);
if (loaded) {
loaded = false;
@@ -197,7 +198,7 @@ CmpSelectDlg::ExecFrame()
bool
CmpSelectDlg::CanClose()
{
- AutoThreadSync a(sync);
+ const std::lock_guard<std::mutex> lock(sync);
return !loading;
}
@@ -206,7 +207,7 @@ CmpSelectDlg::CanClose()
void
CmpSelectDlg::ShowNewCampaigns()
{
- AutoThreadSync a(sync);
+ const std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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;
}