akgl_heap_release* should not cascade into dependent objects (releasing actors should not release characters, sprites, and spritesheets)

This commit is contained in:
2026-05-13 22:45:52 -04:00
parent 9443fa8532
commit aad196d84e
2 changed files with 5 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
#ifndef _SDL_GAMECONTROLLERDB_H_ #ifndef _SDL_GAMECONTROLLERDB_H_
#define _SDL_GAMECONTROLLERDB_H_ #define _SDL_GAMECONTROLLERDB_H_
// Taken from https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt on Wed May 13 07:27:47 PM EDT 2026 // Taken from https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/refs/heads/master/gamecontrollerdb.txt on Wed May 13 10:44:28 PM EDT 2026
#define AKGL_SDL_GAMECONTROLLER_DB_LEN 2228 #define AKGL_SDL_GAMECONTROLLER_DB_LEN 2228

View File

@@ -118,9 +118,6 @@ akerr_ErrorContext *akgl_heap_release_actor(akgl_Actor *ptr)
CATCH_AND_RETURN(errctx, akgl_heap_release_actor(ptr->children[i])); CATCH_AND_RETURN(errctx, akgl_heap_release_actor(ptr->children[i]));
} }
} }
if ( ptr->basechar != NULL ) {
CATCH_AND_RETURN(errctx, akgl_heap_release_character(ptr->basechar));
}
SDL_ClearProperty(AKGL_REGISTRY_ACTOR, (char *)&ptr->name); SDL_ClearProperty(AKGL_REGISTRY_ACTOR, (char *)&ptr->name);
memset(ptr, 0x00, sizeof(akgl_Actor)); memset(ptr, 0x00, sizeof(akgl_Actor));
} }
@@ -133,14 +130,13 @@ akerr_ErrorContext *akgl_heap_release_character(akgl_Character *basechar)
akgl_Iterator opflags; akgl_Iterator opflags;
FAIL_ZERO_RETURN(errctx, basechar, AKERR_NULLPOINTER, "NULL character reference"); FAIL_ZERO_RETURN(errctx, basechar, AKERR_NULLPOINTER, "NULL character reference");
AKGL_BITMASK_CLEAR(opflags.flags); AKGL_BITMASK_CLEAR(opflags.flags);
AKGL_BITMASK_ADD(opflags.flags, AKGL_ITERATOR_OP_RELEASE);
if ( basechar->refcount > 0 ) { if ( basechar->refcount > 0 ) {
basechar->refcount -= 1; basechar->refcount -= 1;
} }
if ( basechar->refcount == 0 ) { if ( basechar->refcount == 0 ) {
SDL_EnumerateProperties(basechar->state_sprites, &akgl_character_state_sprites_iterate, (void *)&opflags);
SDL_ClearProperty(AKGL_REGISTRY_CHARACTER, (char *)&basechar->name); SDL_ClearProperty(AKGL_REGISTRY_CHARACTER, (char *)&basechar->name);
memset(basechar, 0x00, sizeof(akgl_Character));
} }
SUCCEED_RETURN(errctx); SUCCEED_RETURN(errctx);
} }
@@ -153,12 +149,8 @@ akerr_ErrorContext *akgl_heap_release_sprite(akgl_Sprite *ptr)
ptr->refcount -= 1; ptr->refcount -= 1;
} }
if ( ptr->refcount == 0 ) { if ( ptr->refcount == 0 ) {
ATTEMPT { SDL_ClearProperty(AKGL_REGISTRY_SPRITE, (char *)&ptr->name);
CATCH(errctx, akgl_heap_release_spritesheet(ptr->sheet)); memset(ptr, 0x00, sizeof(akgl_Sprite));
} CLEANUP {
SDL_ClearProperty(AKGL_REGISTRY_SPRITE, (char *)&ptr->name);
} PROCESS(errctx) {
} FINISH(errctx, true);
} }
SUCCEED_RETURN(errctx); SUCCEED_RETURN(errctx);
} }
@@ -176,6 +168,7 @@ akerr_ErrorContext *akgl_heap_release_spritesheet(akgl_SpriteSheet *ptr)
if ( ptr-> texture != NULL ) if ( ptr-> texture != NULL )
SDL_DestroyTexture(ptr->texture); SDL_DestroyTexture(ptr->texture);
ptr->texture = NULL; ptr->texture = NULL;
memset(ptr, 0x00, sizeof(akgl_SpriteSheet));
} }
SUCCEED_RETURN(errctx); SUCCEED_RETURN(errctx);
} }