mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 18:29:24 +08:00
Fix crashing in Windows Insiders builds (#2562)
Added missing initialization of winrt apartment
This commit is contained in:
parent
6cd0f83496
commit
0f6563e8e0
@ -227,6 +227,8 @@ void XamlBridge::OnTakeFocusRequested(winrt::Windows::UI::Xaml::Hosting::Desktop
|
|||||||
HWND XamlBridge::InitDesktopWindowsXamlSource(winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource desktopSource)
|
HWND XamlBridge::InitDesktopWindowsXamlSource(winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource desktopSource)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
winrt::init_apartment(apartment_type::single_threaded);
|
||||||
|
winxamlmanager = WindowsXamlManager::InitializeForCurrentThread();
|
||||||
|
|
||||||
auto interop = desktopSource.as<IDesktopWindowXamlSourceNative>();
|
auto interop = desktopSource.as<IDesktopWindowXamlSourceNative>();
|
||||||
// Parent the DesktopWindowXamlSource object to current window
|
// Parent the DesktopWindowXamlSource object to current window
|
||||||
@ -258,6 +260,8 @@ void XamlBridge::ClearXamlIslands()
|
|||||||
xamlSource.Close();
|
xamlSource.Close();
|
||||||
}
|
}
|
||||||
m_xamlSources.clear();
|
m_xamlSources.clear();
|
||||||
|
|
||||||
|
winxamlmanager.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function invoked when the window is destroyed
|
// Function invoked when the window is destroyed
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
XamlBridge(HWND parent) :
|
XamlBridge(HWND parent) :
|
||||||
parentWindow(parent), lastFocusRequestId(winrt::guid())
|
parentWindow(parent), lastFocusRequestId(winrt::guid()), winxamlmanager(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +37,9 @@ private:
|
|||||||
// Stores the handle of the parent native window
|
// Stores the handle of the parent native window
|
||||||
HWND parentWindow = nullptr;
|
HWND parentWindow = nullptr;
|
||||||
|
|
||||||
|
// Window xaml manager for UI thread.
|
||||||
|
WindowsXamlManager winxamlmanager;
|
||||||
|
|
||||||
// Stores the GUID of the last focus request
|
// Stores the GUID of the last focus request
|
||||||
winrt::guid lastFocusRequestId;
|
winrt::guid lastFocusRequestId;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user