Sfoglia il codice sorgente

Removed SDL_INIT_EVERYTHING

Fixes https://github.com/libsdl-org/SDL/issues/8709
Sam Lantinga 1 anno fa
parent
commit
c540c77756

+ 1 - 1
cmake/test/inc_sdl_noslash.c

@@ -3,6 +3,6 @@
 
 void inc_sdl_noslash(void) {
     SDL_SetMainReady();
-    SDL_Init(SDL_INIT_EVERYTHING);
+    SDL_Init(0);
     SDL_Quit();
 }

+ 1 - 1
cmake/test/inc_sdl_slash.c

@@ -3,6 +3,6 @@
 
 void inc_sdl_slash(void) {
     SDL_SetMainReady();
-    SDL_Init(SDL_INIT_EVERYTHING);
+    SDL_Init(0);
     SDL_Quit();
 }

+ 1 - 0
docs/README-migration.md

@@ -716,6 +716,7 @@ The following symbols have been renamed:
 
 The following symbols have been removed:
 * SDL_INIT_NOPARACHUTE
+* SDL_INIT_EVERYTHING - you should only initialize the subsystems you are using
 
 ## SDL_joystick.h
 

+ 1 - 5
include/SDL3/SDL_init.h

@@ -61,10 +61,6 @@ typedef enum
     SDL_INIT_EVENTS       = 0x00004000,
     SDL_INIT_SENSOR       = 0x00008000
 } SDL_InitFlags;
-#define SDL_INIT_EVERYTHING ( \
-                SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
-                SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMEPAD | SDL_INIT_SENSOR \
-            )
 
 /**
  * Initialize the SDL library.
@@ -94,7 +90,7 @@ typedef enum
  * - `SDL_INIT_GAMEPAD`: gamepad subsystem; automatically initializes the
  *   joystick subsystem
  * - `SDL_INIT_EVENTS`: events subsystem
- * - `SDL_INIT_EVERYTHING`: all of the above subsystems
+ * - `SDL_INIT_SENSOR`: sensor subsystem
  *
  * Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem()
  * for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or

+ 2 - 0
src/SDL.c

@@ -47,6 +47,8 @@
 #include "joystick/SDL_joystick_c.h"
 #include "sensor/SDL_sensor_c.h"
 
+#define SDL_INIT_EVERYTHING ~0U
+
 /* Initialization/Cleanup routines */
 #include "timer/SDL_timer_c.h"
 #ifdef SDL_VIDEO_DRIVER_WINDOWS

+ 2 - 2
test/testautomation_platform.c

@@ -256,12 +256,12 @@ static int platform_testDefaultInit(void *arg)
     int ret;
     int subsystem;
 
-    subsystem = SDL_WasInit(SDL_INIT_EVERYTHING);
+    subsystem = SDL_WasInit(0);
     SDLTest_AssertCheck(subsystem != 0,
                         "SDL_WasInit(0): returned %i, expected != 0",
                         subsystem);
 
-    ret = SDL_Init(SDL_WasInit(SDL_INIT_EVERYTHING));
+    ret = SDL_Init(0);
     SDLTest_AssertCheck(ret == 0,
                         "SDL_Init(0): returned %i, expected 0, error: %s",
                         ret,

+ 3 - 3
test/testautomation_subsystems.c

@@ -15,12 +15,12 @@ static void subsystemsSetUp(void *arg)
     /* CHECKME: can we use SDL_Quit here, or this will break the flow of tests? */
     SDL_Quit();
     /* Alternate variant without SDL_Quit:
-        while (SDL_WasInit(SDL_INIT_EVERYTHING) != 0) {
-            SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
+        while (SDL_WasInit(0) != 0) {
+            SDL_QuitSubSystem(~0U);
         }
     */
     SDLTest_AssertPass("Reset all subsystems before subsystems test");
-    SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_EVERYTHING) == 0, "Check result from SDL_WasInit(SDL_INIT_EVERYTHING)");
+    SDLTest_AssertCheck(SDL_WasInit(0) == 0, "Check result from SDL_WasInit(0)");
 }
 
 static void subsystemsTearDown(void *arg)