Skip to content

Commit 6a73195

Browse files
MattGuerretteocornut
authored andcommitted
Backends: SDL3: following SDL3 reverting their change, result of SDL_GetGamepads must be freed. (#7918, #7898, #7807)
1 parent ee9e3a2 commit 6a73195

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

backends/imgui_impl_sdl3.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
// CHANGELOG
2323
// (minor and older changes stripped away, please see git history for details)
24+
// 2024-09-03: Update for SDL3 api changes: SDL_GetGamepads() memory ownership revert. (#7918, #7898, #7807)
2425
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
2526
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
2627
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
@@ -672,7 +673,7 @@ static void ImGui_ImplSDL3_UpdateGamepads()
672673
{
673674
ImGui_ImplSDL3_CloseGamepads();
674675
int sdl_gamepads_count = 0;
675-
const SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
676+
SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
676677
for (int n = 0; n < sdl_gamepads_count; n++)
677678
if (SDL_Gamepad* gamepad = SDL_OpenGamepad(sdl_gamepads[n]))
678679
{
@@ -681,6 +682,7 @@ static void ImGui_ImplSDL3_UpdateGamepads()
681682
break;
682683
}
683684
bd->WantUpdateGamepadsList = false;
685+
SDL_free(sdl_gamepads);
684686
}
685687

686688
// FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.

docs/CHANGELOG.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ Other changes:
9696
provide a way to do a portable sleep. (#7844)
9797
- Backends: SDL2, SDL3: ignore events of other SDL windows. (#7853) [@madebr, @ocornut]
9898
- Backends: SDL2, SDL3: storing SDL_WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
99+
- Backends: SDL3: Update for API changes: SDL_GetGamepads() memory ownership logic was reverted back
100+
by SDL3 on July 27. (#7918, #7898, #7807) [@cheyao, @MattGuerrette]
99101
- Backends: GLFW: passing null window to glfwGetClipboardString()/glfwSetClipboardString()
100102
since GLFW own tests are doing that and it seems unnecessary.
101103
- Backends: SDL2, SDL3, GLFW, OSX, Allegro: update to set function handlers in ImGuiPlatformIO
102104
instead of ImGuiIO.
103105
- Examples: GLFW (all), SDL2 (all), SDL3 (all), Win32+OpenGL3: rework examples main loop
104106
to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
105107

106-
108+
Backends: SDL3: following SDL3 reverting their change, result of SDL_GetGamepads must be freed. (#7918, #7898)
107109

108110
-----------------------------------------------------------------------
109111
VERSION 1.91.0 (Released 2024-07-30)

0 commit comments

Comments
 (0)