From e349130d4e744a9d9d908f4fea4bb4749e40efbb Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Mon, 6 May 2024 16:24:46 -0500 Subject: [PATCH] Fix ed2923ba by backporting HRESULT change from de7f9312 --- src/cascadia/TerminalControl/EventArgs.h | 4 ++-- src/cascadia/TerminalControl/EventArgs.idl | 2 +- src/cascadia/TerminalControl/TermControl.cpp | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cascadia/TerminalControl/EventArgs.h b/src/cascadia/TerminalControl/EventArgs.h index 97798101c57..550ca6d32d1 100644 --- a/src/cascadia/TerminalControl/EventArgs.h +++ b/src/cascadia/TerminalControl/EventArgs.h @@ -120,12 +120,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation struct RendererWarningArgs : public RendererWarningArgsT { public: - RendererWarningArgs(const uint64_t hr) : + RendererWarningArgs(const HRESULT hr) : _Result(hr) { } - WINRT_PROPERTY(uint64_t, Result); + WINRT_PROPERTY(HRESULT, Result); }; struct TransparencyChangedEventArgs : public TransparencyChangedEventArgsT diff --git a/src/cascadia/TerminalControl/EventArgs.idl b/src/cascadia/TerminalControl/EventArgs.idl index ddab6bb1c52..f7951d6619a 100644 --- a/src/cascadia/TerminalControl/EventArgs.idl +++ b/src/cascadia/TerminalControl/EventArgs.idl @@ -63,7 +63,7 @@ namespace Microsoft.Terminal.Control runtimeclass RendererWarningArgs { - UInt64 Result { get; }; + HRESULT Result { get; }; } runtimeclass TransparencyChangedEventArgs diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 56d969cd758..9fc72961b11 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -995,9 +995,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation winrt::fire_and_forget TermControl::_RendererWarning(IInspectable /*sender*/, Control::RendererWarningArgs args) { - // HRESULT is a signed 32-bit integer which would result in a hex output like "-0x7766FFF4", - // but canonically HRESULTs are displayed unsigned as "0x8899000C". See GH#11556. - const auto hr = std::bit_cast(args.Result()); + const auto hr = args.Result(); auto weakThis{ get_weak() }; co_await wil::resume_foreground(Dispatcher()); @@ -1017,8 +1015,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation } else { + // HRESULT is a signed 32-bit integer which would result in a hex output like "-0x7766FFF4", + // but canonically HRESULTs are displayed unsigned as "0x8899000C". See GH#11556. + const auto displayHr = std::bit_cast(hr); message = winrt::hstring{ fmt::format(std::wstring_view{ RS_(L"UnexpectedRendererError") }, - hr) }; + displayHr) }; } auto noticeArgs = winrt::make(NoticeLevel::Warning, std::move(message));