From 6244d25f905cbb9013fa36faaa9426bafa546c97 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Tue, 14 Jul 2026 15:17:21 +0200 Subject: [PATCH] Don't generate SDL events on Atlas shutdown WX may still generate mouse events after calling CVideoMode::Shutdown(), so don't create SDL events triggering assertions. Signed-off-by: Ralph Sennhauser --- source/ps/VideoMode.cpp | 5 +++++ source/ps/VideoMode.h | 1 + .../atlas/GameInterface/Handlers/MiscHandlers.cpp | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/source/ps/VideoMode.cpp b/source/ps/VideoMode.cpp index 6748bc72b3..bc2a73e883 100644 --- a/source/ps/VideoMode.cpp +++ b/source/ps/VideoMode.cpp @@ -963,6 +963,11 @@ SDL_Window* CVideoMode::GetWindow() return m_Window; } +bool CVideoMode::IsInitialized() const +{ + return m_IsInitialised; +} + void CVideoMode::SetWindowIcon() { // The window icon should be kept outside of art/textures/, or else it will be converted diff --git a/source/ps/VideoMode.h b/source/ps/VideoMode.h index 136350fc94..bec23f9da3 100644 --- a/source/ps/VideoMode.h +++ b/source/ps/VideoMode.h @@ -95,6 +95,7 @@ public: int GetBPP() const; bool IsVSyncEnabled() const; + bool IsInitialized() const; int GetDesktopXRes() const; int GetDesktopYRes() const; diff --git a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp index ea01c8cb5b..1a28e2c32e 100644 --- a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp @@ -118,6 +118,9 @@ MESSAGEHANDLER(GuiSwitchPage) MESSAGEHANDLER(GuiMouseButtonEvent) { + if (!g_VideoMode.IsInitialized()) + return; + SDL_Event ev{}; ev.type = msg->pressed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP; ev.button.button = msg->button; @@ -132,6 +135,9 @@ MESSAGEHANDLER(GuiMouseButtonEvent) MESSAGEHANDLER(GuiMouseMotionEvent) { + if (!g_VideoMode.IsInitialized()) + return; + SDL_Event ev{}; ev.type = SDL_MOUSEMOTION; float x, y; @@ -143,6 +149,9 @@ MESSAGEHANDLER(GuiMouseMotionEvent) MESSAGEHANDLER(GuiKeyEvent) { + if (!g_VideoMode.IsInitialized()) + return; + SDL_Event ev{}; ev.type = msg->pressed ? SDL_KEYDOWN : SDL_KEYUP; ev.key.keysym.sym = static_cast(static_cast(msg->sdlkey)); @@ -152,6 +161,9 @@ MESSAGEHANDLER(GuiKeyEvent) MESSAGEHANDLER(GuiCharEvent) { + if (!g_VideoMode.IsInitialized()) + return; + // Simulate special 'text input' events in the SDL // This isn't quite compatible with WXWidget's handling, // so to avoid trouble we only send 'letter-like' ASCII input.