aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-02 23:50:58 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-02 23:50:58 +0200
commit23dc657f0af27bdac887f8d18208d544cc9f010e (patch)
treea2656d96f11f879d6a4233fef736493a1cc39ba6 /c/main.cpp
parentedce20642b6d177ee9877775cbfa9e05ebb4e404 (diff)
downloadEpisodeBrowser-23dc657f0af27bdac887f8d18208d544cc9f010e.tar.gz
Improve wstring_owner, rename to wchar_ptr.
The user-defined conversion function makes the interface a lot simpler AND safer.
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 32187c8..3ec6fee 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -56,7 +56,7 @@ static void UpdateTheme();
void OnTerminate() noexcept
{
const wchar_t* what = L"an exception";
- wstring_owner why;
+ wchar_ptr why;
try {
std::rethrow_exception(std::current_exception());
@@ -65,14 +65,14 @@ void OnTerminate() noexcept
try { why = PlString(t); } catch (...) {}
} catch (const Win32Error& e) {
what = L"a Windows error";
- try { why = wstring_owner::copy(e.WhatW()); } catch (...) {}
+ try { why = wchar_ptr::copy(e.WhatW()); } catch (...) {}
} catch (const std::exception& e) {
- try { why = wstring_owner::from_narrow(e.what()); } catch (...) {}
+ try { why = wchar_ptr::from_narrow(e.what()); } catch (...) {}
} catch (...) {}
wchar_t msg[256] = {0};
if (why)
- wszf(msg, L"Episode Browser was terminated due to %s: %s", what, why.p);
+ wszf(msg, L"Episode Browser was terminated due to %s: %s", what, static_cast<wchar_t*>(why));
else
wszf(msg, L"Episode Browser was terminated due to %s.", what);
@@ -493,13 +493,13 @@ void WaitFor(const char* mod, const char* pred)
static atom_t aThread;
static int bActive;
static int iTimer;
- static wstring_owner activePred;
+ static wchar_ptr activePred;
if (bActive) {
wchar_t msg[256] = {0};
wszf(msg, L"Another task (%s) is active. "
L"Do you want to cancel the existing task and start a new one?",
- activePred.p);
+ static_cast<wchar_t*>(activePred));
if (EBMessageBox(msg, L"Error", MB_YESNO|MB_ICONWARNING) != IDYES)
return;
KillTimer(NULL, iTimer);
@@ -529,7 +529,7 @@ void WaitFor(const char* mod, const char* pred)
Plx(mod,"thread_create",pred,&aThread);
SendMessage(g_hWndStatus, SB_SETTEXT, MAKEWPARAM(1,0), (LPARAM)L".");
if (prefer(iTimer = SetTimer(NULL, -1, 500, proc))) {
- activePred = wstring_owner::from_narrow(pred);
+ activePred = wchar_ptr::from_narrow(pred);
bActive = 1;
}
}