diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index 8fe882b9ad..7d3835398f 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -65,6 +65,7 @@ namespace UICommon { static Config::ConfigChangedCallbackID s_config_changed_callback_id; +static Common::HookableEvent<> s_flush_unsaved_data_event_hook; static void CreateDumpPath(std::string path) { @@ -162,9 +163,15 @@ void Shutdown() Config::Shutdown(); } +[[nodiscard]] Common::EventHook AddFlushUnsavedDataCallback(std::function callback) +{ + return s_flush_unsaved_data_event_hook.Register(std::move(callback)); +} + void FlushUnsavedData() { INFO_LOG_FMT(CORE, "Flushing unsaved data..."); + s_flush_unsaved_data_event_hook.Trigger(); } void InitControllers(const WindowSystemInfo& wsi) diff --git a/Source/Core/UICommon/UICommon.h b/Source/Core/UICommon/UICommon.h index e586283816..991f584089 100644 --- a/Source/Core/UICommon/UICommon.h +++ b/Source/Core/UICommon/UICommon.h @@ -6,6 +6,7 @@ #include #include "Common/CommonTypes.h" +#include "Common/HookableEvent.h" struct WindowSystemInfo; @@ -14,6 +15,8 @@ namespace UICommon void Init(); void Shutdown(); +// Triggered from the Host-thread on Android before a potential process termination. +[[nodiscard]] Common::EventHook AddFlushUnsavedDataCallback(std::function callback); void FlushUnsavedData(); void InitControllers(const WindowSystemInfo& wsi);