JeLLyNinjas / TerminalFighter

5 stars 2 forks source link

Bseto/fix graphics handler memory leak #107

Closed bseto closed 6 years ago

bseto commented 6 years ago

Prior to this change, bool cleanup was used to determine if a SDL_Texture* needed to be cleaned up by the GraphicsHandler.

https://github.com/JeLLyNinjas/TerminalFighter/blob/5709f99229da6e750ebdf0f829e7eafae1df5abd/src/Engine/GraphicsHandler/GraphicsHandler.cpp#L72

However, this can be confusing as a SDL_Surface* can also be passed into a draw function.

This change makes the bool cleanup variable cleanup the SDL_Surface* if it is passed into the draw function. It also now correctly handles the SDL_Texture* that is created - which has to be free'd later by GraphicsHandler.