|
12 | 12 | #include "windows.graphics.h" |
13 | 13 | #include "WindowHelpers.h" |
14 | 14 | #include "Microsoft.UI.Windowing.h" |
| 15 | +#include "FrameworkUdk/Containment.h" |
15 | 16 |
|
| 17 | +//Bug 57693475: [1.6 Servicing][WASDK][Watson Failure] caused by STOWED_EXCEPTION_80070032_Microsoft.UI.Xaml.dll!DirectUI::WindowChrome::SetTitleBar |
| 18 | +#define WINAPPSDK_CHANGEID_57693475 57693475 |
16 | 19 |
|
17 | 20 | using namespace DirectUI; |
18 | 21 | namespace RectHelpers = WindowHelpers::RectHelpers; |
@@ -94,16 +97,34 @@ _Check_return_ HRESULT WindowChrome::SetTitleBar(_In_opt_ xaml::IUIElement* titl |
94 | 97 | ctl::ComPtr<ixp::IAppWindow> appWindow; |
95 | 98 | IFC_RETURN(GetDesktopWindowNoRef()->get_AppWindowImpl(&appWindow)); |
96 | 99 |
|
97 | | - if (!appWindow) |
| 100 | + if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_57693475>()) |
98 | 101 | { |
99 | | - // custom titlebar code is being run in a scenario where appwindow is null and thus |
100 | | - // it cannot continue to run. it is running in an unsupported scenario. |
101 | | - // one such scenario is where a top level window is reparented to become a child window of another window |
102 | | - IFCFAILFAST(E_NOTSUPPORTED); |
| 102 | + // SetTitleBar gets called with titleBar as nullptr during window close operations |
| 103 | + // If the window is not a top level window, we should not failfast here |
| 104 | + if (!appWindow && titleBar) |
| 105 | + { |
| 106 | + // custom titlebar code is being run in a scenario where appwindow is null and thus |
| 107 | + // it cannot continue to run. it is running in an unsupported scenario. |
| 108 | + // one such scenario is where a top level window is reparented to become a child window of another window |
| 109 | + IFCFAILFAST(E_NOTSUPPORTED); |
| 110 | + } |
| 111 | + } |
| 112 | + else |
| 113 | + { |
| 114 | + if (!appWindow) |
| 115 | + { |
| 116 | + // custom titlebar code is being run in a scenario where appwindow is null and thus |
| 117 | + // it cannot continue to run. it is running in an unsupported scenario. |
| 118 | + // one such scenario is where a top level window is reparented to become a child window of another window |
| 119 | + IFCFAILFAST(E_NOTSUPPORTED); |
| 120 | + } |
| 121 | + } |
| 122 | + if (appWindow) |
| 123 | + { |
| 124 | + IFC_RETURN(appWindow->get_Id(&windowId)); |
| 125 | + |
| 126 | + IFC_RETURN(inputNonClientPtrSrcStatics->GetForWindowId(windowId, &m_inputNonClientPtrSrc)); |
103 | 127 | } |
104 | | - IFC_RETURN(appWindow->get_Id(&windowId)); |
105 | | - |
106 | | - IFC_RETURN(inputNonClientPtrSrcStatics->GetForWindowId(windowId, &m_inputNonClientPtrSrc)); |
107 | 128 | } |
108 | 129 |
|
109 | 130 | //detach everything from existing titlebar |
|
0 commit comments