Renderer/WindowSwapchain: Fix calls to GetSize() happening after window destruction

This commit is contained in:
SirLynix 2024-01-28 13:56:06 +01:00
parent 01d3795dae
commit f06752b08d
1 changed files with 11 additions and 1 deletions

View File

@ -32,7 +32,16 @@ namespace Nz
const Vector2ui& WindowSwapchain::GetSize() const
{
return (m_swapchain) ? m_swapchain->GetSize() : m_window->GetSize();
if (m_swapchain)
return m_swapchain->GetSize();
else if (m_window)
return m_window->GetSize();
else
{
// Window has been destroyed, return a dummy size
static constexpr Vector2ui dummySize(1, 1);
return dummySize;
}
}
void WindowSwapchain::ConnectSignals()
@ -53,6 +62,7 @@ namespace Nz
OnSwapchainDestroy(this);
m_swapchain.reset();
m_isMinimized = true;
m_window = nullptr;
});
m_onGainedFocus.Connect(windowEvents.OnGainedFocus, [this](const WindowEventHandler* /*eventHandler*/)