Skip to content

Commit

Permalink
Fixed bug 3290 - showimage leaks renderer and doesn't call SDL_VideoQuit
Browse files Browse the repository at this point in the history
Juha Niemim?ki

I was testing SDL_image2 on AmigaOS 4 platform. Noticed a couple of issues with 'showimage' tool:

1) SDL_VideoInit seems to be called implicitly via window creation. SDL_Quit doesn't call SDL_VideoQuit so it doesn't close video device, windows etc. properly. Proposal: add SDL_Init(SDL_INIT_VIDEO) in the beginning for symmetrical video init/deinit.

2) Renderer is not destroyed at the end. As far as I know SDL2 doesn't automatically delete renderers. Proposal: add SDL_DestroyRenderer(renderer) at the end.
  • Loading branch information
slouken committed Sep 12, 2017
1 parent 20c7fd7 commit 84bff81
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions showimage.c
Expand Up @@ -76,6 +76,11 @@ int main(int argc, char *argv[])
}
}

if (SDL_Init(SDL_INIT_VIDEO) == -1) {
fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) failed: %s\n", SDL_GetError());
return(2);
}

if (SDL_CreateWindowAndRenderer(0, 0, flags, &window, &renderer) < 0) {
fprintf(stderr, "SDL_CreateWindowAndRenderer() failed: %s\n", SDL_GetError());
return(2);
Expand Down Expand Up @@ -169,6 +174,10 @@ int main(int argc, char *argv[])
SDL_DestroyTexture(texture);
}


SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);

/* We're done! */
SDL_Quit();
return(0);
Expand Down

0 comments on commit 84bff81

Please sign in to comment.