mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-29 22:48:30 +00:00
tray: improved error checking
Also clean up any existing trays when the program quits Fixes https://github.com/libsdl-org/SDL/issues/11893
This commit is contained in:
@@ -178,6 +178,22 @@ bool SDL_ObjectValid(void *object, SDL_ObjectType type)
|
||||
return (((SDL_ObjectType)(uintptr_t)object_type) == type);
|
||||
}
|
||||
|
||||
int SDL_GetObjects(SDL_ObjectType type, void **objects, int count)
|
||||
{
|
||||
const void *object, *object_type;
|
||||
void *iter = NULL;
|
||||
int num_objects = 0;
|
||||
while (SDL_IterateHashTable(SDL_objects, &object, &object_type, &iter)) {
|
||||
if ((SDL_ObjectType)(uintptr_t)object_type == type) {
|
||||
if (num_objects < count) {
|
||||
objects[num_objects] = (void *)object;
|
||||
}
|
||||
++num_objects;
|
||||
}
|
||||
}
|
||||
return num_objects;
|
||||
}
|
||||
|
||||
void SDL_SetObjectsInvalid(void)
|
||||
{
|
||||
if (SDL_ShouldQuit(&SDL_objects_init)) {
|
||||
@@ -217,6 +233,9 @@ void SDL_SetObjectsInvalid(void)
|
||||
case SDL_OBJECT_TYPE_THREAD:
|
||||
type = "thread";
|
||||
break;
|
||||
case SDL_OBJECT_TYPE_TRAY:
|
||||
type = "SDL_Tray";
|
||||
break;
|
||||
default:
|
||||
type = "unknown object";
|
||||
break;
|
||||
|
Reference in New Issue
Block a user