aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-07 00:23:05 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-07 00:23:05 +0200
commitbea4e9f8740c1bf3ebe80d95ab6e749cfb5de605 (patch)
tree4cb5f38be61325d1c1743faff310bca9fc838e68
parent6faaff8f4f70e31d3d390aa0bf6982bec4ff2932 (diff)
downloadEpisodeBrowser-bea4e9f8740c1bf3ebe80d95ab6e749cfb5de605.tar.gz
Simplify WaitFor.
-rw-r--r--c/main.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 237cc22..449863b 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -382,7 +382,7 @@ LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam,
return 0;
}
-void HandleMainMenu(const HWND hWnd, WORD command)
+void HandleMainMenu(const HWND hWnd, const WORD command)
{
switch (command) {
case IDM_FILE_EXIT:
@@ -438,7 +438,7 @@ void HandleMainMenu(const HWND hWnd, WORD command)
}
}
-void HandleContextMenu(const HWND, WORD command)
+void HandleContextMenu(const HWND, const WORD command)
{
int cNotFound = 0;
@@ -498,12 +498,11 @@ void HandleContextMenu(const HWND, WORD command)
void WaitFor(const char* mod, const char* pred)
{
- static atom_t aThread;
- static bool bActive;
- static int iTimer;
static WcharPtr activePred;
+ static UINT_PTR iTimer;
+ static atom_t aThread;
- if (bActive) {
+ if (activePred) {
wchar_t msg[256] = {0};
Swprintf(msg, L"Another task (%s) is active. "
L"Do you want to cancel the existing task and start a new one?",
@@ -511,7 +510,7 @@ void WaitFor(const char* mod, const char* pred)
if (EBMessageBox(msg, L"Error", MB_YESNO|MB_ICONWARNING) != IDYES)
return;
KillTimer(nullptr, iTimer);
- bActive = false;
+ activePred = nullptr;
g_elv->Update();
}
@@ -530,17 +529,15 @@ void WaitFor(const char* mod, const char* pred)
} else {
KillTimer(nullptr, iTimer);
i = 0;
- bActive = false;
+ activePred = nullptr;
g_elv->Update();
}
};
Plx(mod,"thread_create",pred,&aThread);
SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), reinterpret_cast<LPARAM>(L"."));
- if (Prefer(iTimer = SetTimer(nullptr, -1, 500, proc))) {
+ if (Prefer(iTimer = SetTimer(nullptr, -1, 500, proc)))
activePred = WcharPtr::FromNarrow(pred);
- bActive = true;
- }
}
INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM)