From c24a01d7d993ca974774fccd24d3b9b00568ecd1 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Sun, 29 Jul 2018 01:43:00 +0500 Subject: [PATCH] Fixed quitting from xrWeatherEditor Call SDL_PumpEvents() in on_idle() just in case --- src/Include/editor/engine.hpp | 1 + src/editors/xrWeatherEditor/entry_point.cpp | 2 +- src/xrEngine/engine_impl.cpp | 12 +++++++++++- src/xrEngine/engine_impl.hpp | 1 + src/xrEngine/main.cpp | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Include/editor/engine.hpp b/src/Include/editor/engine.hpp index e9337e76a86..f39f3fb3d31 100644 --- a/src/Include/editor/engine.hpp +++ b/src/Include/editor/engine.hpp @@ -25,6 +25,7 @@ class engine_base virtual void pause(bool const& value) = 0; virtual void capture_input(bool const& value) = 0; virtual void disconnect() = 0; + virtual bool quit_requested() const = 0; // shared_str support virtual void value(LPCSTR value, shared_str& result) = 0; virtual LPCSTR value(shared_str const& value) = 0; diff --git a/src/editors/xrWeatherEditor/entry_point.cpp b/src/editors/xrWeatherEditor/entry_point.cpp index 69a3d6f700c..205762e95f0 100644 --- a/src/editors/xrWeatherEditor/entry_point.cpp +++ b/src/editors/xrWeatherEditor/entry_point.cpp @@ -55,7 +55,7 @@ private ref class window_ide_final : public editor::window_ide { m_engine->on_idle(); impl->on_idle(); - } while (m_engine&&!PeekMessage(&message, HWND(0), 0, 0, 0)); + } while (m_engine && !m_engine->quit_requested() && !PeekMessage(&message, HWND(0), 0, 0, 0)); impl->on_idle_end(); } diff --git a/src/xrEngine/engine_impl.cpp b/src/xrEngine/engine_impl.cpp index de2a5f343cf..d7182fdd845 100644 --- a/src/xrEngine/engine_impl.cpp +++ b/src/xrEngine/engine_impl.cpp @@ -31,7 +31,11 @@ bool engine_impl::on_message(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, return (Device.on_message(hWnd, uMsg, wParam, lParam, result)); } -void engine_impl::on_idle() { Device.on_idle(); } +void engine_impl::on_idle() +{ + SDL_PumpEvents(); + Device.on_idle(); +} void engine_impl::on_resize() { if (Console) @@ -60,6 +64,12 @@ void engine_impl::capture_input(bool const& value) } void engine_impl::disconnect() { Console->Execute("quit"); } + +bool engine_impl::quit_requested() const +{ + return SDL_QuitRequested(); +} + void engine_impl::value(LPCSTR value, shared_str& result) { result = value; } LPCSTR engine_impl::value(shared_str const& value) { return (value.c_str()); } void engine_impl::weather(LPCSTR value) diff --git a/src/xrEngine/engine_impl.hpp b/src/xrEngine/engine_impl.hpp index 23c0c439950..853e06d3063 100644 --- a/src/xrEngine/engine_impl.hpp +++ b/src/xrEngine/engine_impl.hpp @@ -24,6 +24,7 @@ class engine_impl : public XRay::Editor::engine_base virtual void pause(bool const& value); virtual void capture_input(bool const& value); virtual void disconnect(); + bool quit_requested() const override; virtual void value(LPCSTR value, shared_str& result); virtual LPCSTR value(shared_str const& value); diff --git a/src/xrEngine/main.cpp b/src/xrEngine/main.cpp index 3d5c03059ac..e257941a59c 100644 --- a/src/xrEngine/main.cpp +++ b/src/xrEngine/main.cpp @@ -110,7 +110,7 @@ ENGINE_API void InitConsole() ENGINE_API void InitInput() { - bool captureInput = !strstr(Core.Params, "-i"); + bool captureInput = !strstr(Core.Params, "-i") && !GEnv.isEditor; pInput = new CInput(captureInput); }