mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-02 07:58:30 +00:00
render: SDL_DestroyWindow hollows out its renderer but doesn't free it.
This allows apps to destroy the window and renderer in either order, but makes sure that the renderer can properly clean up its resources while OpenGL contexts and libraries are still loaded, etc. If the window is destroyed first, the renderer is (mostly) destroyed but its pointer remains valid. Attempts to use the renderer will return an error, but it can still be explicitly destroyed, at which time the struct is free'd. If the renderer is destroyed first, everything works as before, and a new renderer can still be created on the existing window. Fixes #9540.
This commit is contained in:
@@ -289,6 +289,8 @@ struct SDL_Renderer
|
||||
|
||||
SDL_PropertiesID props;
|
||||
|
||||
SDL_bool destroyed; // already destroyed by SDL_DestroyWindow; just free this struct in SDL_DestroyRenderer.
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
@@ -335,6 +337,9 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode
|
||||
the next call, because it might be in an array that gets realloc()'d. */
|
||||
extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
|
||||
|
||||
// Let the video subsystem destroy a renderer without making its pointer invalid.
|
||||
extern void SDL_DestroyRendererWithoutFreeing(SDL_Renderer *renderer);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user