Skip to content

Commit

Permalink
UWP: Fix possible crash on startup in SizeChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Oct 25, 2021
1 parent ccf5006 commit 48ddebd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/duckstation-uwp/uwp_host_interface.cpp
Expand Up @@ -145,8 +145,8 @@ bool UWPHostInterface::CreateDisplay(bool fullscreen)
GAMING_DEVICE_MODEL_INFORMATION gdinfo = {};
if (SUCCEEDED(GetGamingDeviceModelInformation(&gdinfo)) && gdinfo.vendorId == GAMING_DEVICE_VENDOR_ID_MICROSOFT)
{
Log_InfoPrintf("Overriding core window size %ux%u with HDMI size %ux%u", wi.surface_width,
wi.surface_height, hdmi_width, hdmi_height);
Log_InfoPrintf("Overriding core window size %ux%u with HDMI size %ux%u", wi.surface_width, wi.surface_height,
hdmi_width, hdmi_height);
wi.surface_scale *= static_cast<float>(hdmi_width) / static_cast<float>(wi.surface_width);
wi.surface_width = hdmi_width;
wi.surface_height = hdmi_height;
Expand Down Expand Up @@ -501,13 +501,17 @@ void UWPHostInterface::OnClosed(const IInspectable&, const winrt::Windows::UI::C
void UWPHostInterface::OnSizeChanged(const IInspectable&,
const winrt::Windows::UI::Core::WindowSizeChangedEventArgs& args)
{
const auto size = args.Size();
const s32 width = static_cast<s32>(size.Width * m_display->GetWindowScale());
const s32 height = static_cast<s32>(size.Height * m_display->GetWindowScale());
if (IsEmulationThreadRunning())
{
const auto size = args.Size();
const float width = size.Width;
const float height = size.Height;
RunLater([this, width, height]() {
m_display->ResizeRenderWindow(width, height);
if (!m_display)
return;

m_display->ResizeRenderWindow(static_cast<s32>(width * m_display->GetWindowScale()),
static_cast<s32>(height * m_display->GetWindowScale()));
OnHostDisplayResized();
});
}
Expand Down

0 comments on commit 48ddebd

Please sign in to comment.