Fix crash when window gets deleted before show/close sequence
This commit is contained in:
@@ -125,6 +125,7 @@ WindowBase::~WindowBase()
|
|||||||
{
|
{
|
||||||
ASSERT(!RenderTask);
|
ASSERT(!RenderTask);
|
||||||
ASSERT(!_swapChain);
|
ASSERT(!_swapChain);
|
||||||
|
WindowsManager::Unregister((Window*)this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowBase::IsMain() const
|
bool WindowBase::IsMain() const
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ WindowsManagerService WindowsManagerServiceInstance;
|
|||||||
Window* WindowsManager::GetByNativePtr(void* handle)
|
Window* WindowsManager::GetByNativePtr(void* handle)
|
||||||
{
|
{
|
||||||
Window* result = nullptr;
|
Window* result = nullptr;
|
||||||
|
|
||||||
WindowsLocker.Lock();
|
WindowsLocker.Lock();
|
||||||
for (int32 i = 0; i < Windows.Count(); i++)
|
for (int32 i = 0; i < Windows.Count(); i++)
|
||||||
{
|
{
|
||||||
@@ -36,7 +35,6 @@ Window* WindowsManager::GetByNativePtr(void* handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
WindowsLocker.Unlock();
|
WindowsLocker.Unlock();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +59,7 @@ void WindowsManagerService::Update()
|
|||||||
// Update windows
|
// Update windows
|
||||||
const float deltaTime = Time::Update.UnscaledDeltaTime.GetTotalSeconds();
|
const float deltaTime = Time::Update.UnscaledDeltaTime.GetTotalSeconds();
|
||||||
WindowsManager::WindowsLocker.Lock();
|
WindowsManager::WindowsLocker.Lock();
|
||||||
for (auto& win : WindowsManager::Windows)
|
for (Window* win : WindowsManager::Windows)
|
||||||
{
|
{
|
||||||
if (win && win->IsVisible())
|
if (win && win->IsVisible())
|
||||||
win->OnUpdate(deltaTime);
|
win->OnUpdate(deltaTime);
|
||||||
@@ -74,7 +72,7 @@ void WindowsManagerService::Dispose()
|
|||||||
// Close remaining windows
|
// Close remaining windows
|
||||||
WindowsManager::WindowsLocker.Lock();
|
WindowsManager::WindowsLocker.Lock();
|
||||||
auto windows = WindowsManager::Windows;
|
auto windows = WindowsManager::Windows;
|
||||||
for (auto& win : windows)
|
for (Window* win : windows)
|
||||||
{
|
{
|
||||||
win->Close(ClosingReason::EngineExit);
|
win->Close(ClosingReason::EngineExit);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user