mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 19:49:11 +08:00
fix sdl memory leak
This commit is contained in:
parent
e296dcfe7e
commit
9b210a0ae4
@ -297,6 +297,8 @@ extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id);
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*));
|
||||
|
||||
extern DECLSPEC void SDLCALL SDL_TLSCleanup();
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
@ -83,7 +83,7 @@ SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *))
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
SDL_TLSCleanup()
|
||||
{
|
||||
SDL_TLSData *storage;
|
||||
|
@ -2871,6 +2871,7 @@ SDL_VideoQuit(void)
|
||||
_this->displays = NULL;
|
||||
_this->num_displays = 0;
|
||||
}
|
||||
SDL_TLSCleanup();
|
||||
SDL_free(_this->clipboard_text);
|
||||
_this->clipboard_text = NULL;
|
||||
_this->free(_this);
|
||||
|
@ -163,10 +163,6 @@ static ret_t native_window_sdl_close(native_window_t* win) {
|
||||
SDL_DestroyRenderer(sdl->render);
|
||||
}
|
||||
|
||||
if (sdl->window != NULL) {
|
||||
SDL_DestroyWindow(sdl->window);
|
||||
}
|
||||
|
||||
if (sdl->context != NULL) {
|
||||
SDL_GL_DeleteContext(sdl->context);
|
||||
}
|
||||
@ -605,6 +601,13 @@ ret_t native_window_sdl_init(bool_t shared, uint32_t w, uint32_t h) {
|
||||
|
||||
ret_t native_window_sdl_deinit(void) {
|
||||
if (s_shared_win != NULL) {
|
||||
native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(s_shared_win);
|
||||
|
||||
if (sdl->cursor_surface != NULL) {
|
||||
SDL_FreeSurface(sdl->cursor_surface);
|
||||
sdl->cursor_surface = NULL;
|
||||
}
|
||||
|
||||
object_unref(OBJECT(s_shared_win));
|
||||
s_shared_win = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user