mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-03 08:28:29 +00:00
Always enable object validation when checking is explicitly enabled
This commit is contained in:
@@ -291,11 +291,13 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
||||
// If you define SDL_DISABLE_INVALID_PARAMS, you're promising that you'll
|
||||
// never pass an invalid parameter to SDL, since it may crash or lead to
|
||||
// hard to diagnose bugs. Let's assert that this is true in debug builds.
|
||||
#define OBJECT_VALIDATION_REQUIRED
|
||||
#define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (false)
|
||||
#else
|
||||
#define CHECK_PARAM(invalid) if (false)
|
||||
#endif
|
||||
#elif defined(SDL_ASSERT_INVALID_PARAMS)
|
||||
#define OBJECT_VALIDATION_REQUIRED
|
||||
#define CHECK_PARAM(invalid) SDL_assert_always(!(invalid)); if (invalid)
|
||||
#else
|
||||
#define CHECK_PARAM(invalid) if (invalid)
|
||||
|
@@ -137,12 +137,13 @@ Uint32 SDL_GetNextObjectID(void)
|
||||
|
||||
static SDL_InitState SDL_objects_init;
|
||||
static SDL_HashTable *SDL_objects;
|
||||
bool SDL_object_validation = false;
|
||||
bool SDL_object_validation = true;
|
||||
|
||||
static void SDLCALL SDL_InvalidParamChecksChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
bool validation_enabled = true;
|
||||
|
||||
#ifndef OBJECT_VALIDATION_REQUIRED
|
||||
if (hint) {
|
||||
switch (*hint) {
|
||||
case '0':
|
||||
@@ -156,6 +157,8 @@ static void SDLCALL SDL_InvalidParamChecksChanged(void *userdata, const char *na
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // !OBJECT_VALIDATION_REQUIRED
|
||||
|
||||
SDL_object_validation = validation_enabled;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user