From 09f552639a98f342455f1baa2b44abf6bb3350c3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 8 Apr 2020 09:00:10 -0700 Subject: [PATCH] Fixed memory leak and removed debug code from Windows sensor implementation --- src/sensor/windows/SDL_windowssensor.c | 5 +++-- test/testgamecontroller.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c index 6ec80e1edd781..6b9fac4b07e55 100644 --- a/src/sensor/windows/SDL_windowssensor.c +++ b/src/sensor/windows/SDL_windowssensor.c @@ -281,6 +281,9 @@ static int ConnectSensor(ISensor *sensor) } else { name = SDL_strdup("Unknown Sensor"); } + if (bstr_name != NULL) { + SysFreeString(bstr_name); + } if (!name) { return SDL_OutOfMemory(); } @@ -339,8 +342,6 @@ SDL_WINDOWS_SensorInit(void) HRESULT hr; ISensorCollection *sensor_collection = NULL; - while (!IsDebuggerPresent()) Sleep(100); - if (WIN_CoInitialize() == S_OK) { SDL_windowscoinit = SDL_TRUE; } diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index 9fd5eb5042ed1..e23dedc135a3e 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -261,6 +261,8 @@ main(int argc, char *argv[]) /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + SDL_SetHint( SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1" ); + /* Initialize SDL (Note: video is required to start event loop) */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());