IO: restore default platform handlers on ClearPlatformHandlers. (#9537, #8945, #2769)

Amend d4f722d5b.
This commit is contained in:
Lukasz Stalmirski
2026-09-03 21:40:20 +02:00
committed by ocornut
parent 4898533613
commit 4ebb04333b
2 changed files with 14 additions and 6 deletions

View File

@@ -1387,10 +1387,9 @@ static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSetti
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
// Platform Dependents default implementation for ImGuiPlatformIO functions
static void InitializeDefaultPlatformHandlers(ImGuiPlatformIO& platform_io);
static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx);
static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext* ctx, const char* text);
static void Platform_SetImeDataFn_DefaultImpl(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
static bool Platform_OpenInShellFn_DefaultImpl(ImGuiContext* ctx, const char* path);
namespace ImGui
{
@@ -4486,10 +4485,7 @@ void ImGui::Initialize()
LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_COUNTOF(GLocalizationEntriesEnUS));
// Setup default ImGuiPlatformIO clipboard/IME handlers.
g.PlatformIO.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
g.PlatformIO.Platform_SetClipboardTextFn = Platform_SetClipboardTextFn_DefaultImpl;
g.PlatformIO.Platform_OpenInShellFn = Platform_OpenInShellFn_DefaultImpl;
g.PlatformIO.Platform_SetImeDataFn = Platform_SetImeDataFn_DefaultImpl;
InitializeDefaultPlatformHandlers(g.PlatformIO);
// Setup session starting date
#ifndef IMGUI_DISABLE_TIME_FUNCTIONS
@@ -16101,6 +16097,7 @@ void ImGuiPlatformIO::ClearPlatformHandlers()
Platform_OpenInShellUserData = NULL;
Platform_SetImeDataFn = NULL;
Platform_ImeUserData = NULL;
InitializeDefaultPlatformHandlers(*this); // Rrevents losing the functionality provided by Platform_*_DefaultImpl on backend re-creation.
}
void ImGuiPlatformIO::ClearRendererHandlers()
@@ -16413,6 +16410,15 @@ static void Platform_SetImeDataFn_DefaultImpl(ImGuiContext*, ImGuiViewport*, ImG
#endif // Default IME handlers
// Setup default ImGuiPlatformIO clipboard/IME handlers
static void InitializeDefaultPlatformHandlers(ImGuiPlatformIO& platform_io)
{
platform_io.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl;
platform_io.Platform_SetClipboardTextFn = Platform_SetClipboardTextFn_DefaultImpl;
platform_io.Platform_OpenInShellFn = Platform_OpenInShellFn_DefaultImpl;
platform_io.Platform_SetImeDataFn = Platform_SetImeDataFn_DefaultImpl;
}
//-----------------------------------------------------------------------------
// [SECTION] METRICS/DEBUGGER WINDOW
//-----------------------------------------------------------------------------