From 39d8b9826da961a8f8766500ba0e365baa31efc8 Mon Sep 17 00:00:00 2001 From: Ghislain Rodrigues Date: Mon, 11 Sep 2017 21:46:24 +0100 Subject: [PATCH 1/3] Comparison to NULL done instead of 0 --- multiplayer_setup_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multiplayer_setup_state.c b/multiplayer_setup_state.c index dc85c0b..44c901b 100644 --- a/multiplayer_setup_state.c +++ b/multiplayer_setup_state.c @@ -210,7 +210,7 @@ void multiplayer_setup_state_render(s_Game* game) { 0, 0, 0 ); - if (errorTexture != 0) { + if (errorTexture != NULL) { SDL_QueryTexture(errorTexture, NULL, NULL, &textWidth, &textHeight); SDL_Rect errorRect = {50, 60, textWidth, textHeight}; SDL_RenderCopy(game->renderer, errorTexture, NULL, &errorRect); @@ -281,7 +281,7 @@ void multiplayer_setup_state_render(s_Game* game) { ); } - if (errorTexture != 0) { + if (errorTexture != NULL) { SDL_QueryTexture(errorTexture, NULL, NULL, &textWidth, &textHeight); SDL_Rect errorRect = {50, 210, textWidth, textHeight}; SDL_RenderCopy(game->renderer, errorTexture, NULL, &errorRect); From 02794f966c0333e4fc1fff2693570903db817e42 Mon Sep 17 00:00:00 2001 From: Ghislain Rodrigues Date: Mon, 11 Sep 2017 21:47:32 +0100 Subject: [PATCH 2/3] delete the texture only if it is null --- multiplayer_setup_state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/multiplayer_setup_state.c b/multiplayer_setup_state.c index 44c901b..95ea671 100644 --- a/multiplayer_setup_state.c +++ b/multiplayer_setup_state.c @@ -356,7 +356,10 @@ void multiplayer_setup_state_handleEvent(s_Game* game, int key) { } void _setSetupError(s_Game *game, const char *errorMessage) { - SDL_DestroyTexture(errorTexture); + if (errorTexture != NULL) { + SDL_DestroyTexture(errorTexture); + } + utils_createTextTexture( game->renderer, game->menuFont, From c36d39567d44ba0bf1a252cde0f4dd15d1e02a42 Mon Sep 17 00:00:00 2001 From: Ghislain Rodrigues Date: Mon, 11 Sep 2017 21:48:06 +0100 Subject: [PATCH 3/3] Texture nulled after being destroyed --- multiplayer_setup_state.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/multiplayer_setup_state.c b/multiplayer_setup_state.c index 95ea671..72555f0 100644 --- a/multiplayer_setup_state.c +++ b/multiplayer_setup_state.c @@ -339,6 +339,7 @@ void multiplayer_setup_state_handleEvent(s_Game* game, int key) { if (key == SDLK_ESCAPE) { g_localState = STATE_HOST_JOIN; SDL_DestroyTexture(errorTexture); + errorTexture = NULL; } else if (IS_GCW) { _handleIPSelectionEventGCW(game, key); @@ -351,6 +352,7 @@ void multiplayer_setup_state_handleEvent(s_Game* game, int key) { if (key == SDLK_ESCAPE) { g_localState = STATE_JOIN_SETUP; SDL_DestroyTexture(errorTexture); + errorTexture = NULL; } } } @@ -358,6 +360,7 @@ void multiplayer_setup_state_handleEvent(s_Game* game, int key) { void _setSetupError(s_Game *game, const char *errorMessage) { if (errorTexture != NULL) { SDL_DestroyTexture(errorTexture); + errorTexture = NULL; } utils_createTextTexture(