From 23dc657f0af27bdac887f8d18208d544cc9f010e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 2 Aug 2022 23:50:58 +0200 Subject: Improve wstring_owner, rename to wchar_ptr. The user-defined conversion function makes the interface a lot simpler AND safer. --- c/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'c/main.cpp') 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(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(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; } } -- cgit v1.2.3