We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3290 - showimage leaks renderer and doesn't call SDL_VideoQuit
Summary: showimage leaks renderer and doesn't call SDL_VideoQuit
Status: RESOLVED FIXED
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.1
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-15 18:11 UTC by Juha Niemimäki
Modified: 2017-09-12 04:23 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juha Niemimäki 2016-03-15 18:11:45 UTC
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.
Comment 1 Sylvain 2017-09-11 19:48:22 UTC
Small patch for this:

--- a/showimage.c	Sat Sep 09 18:57:05 2017 -0700
+++ b/showimage.c	Mon Sep 11 21:47:56 2017 +0200
@@ -76,6 +76,11 @@
         }
     }
 
+    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);
@@ -169,6 +174,10 @@
         SDL_DestroyTexture(texture);
     }
 
+
+    SDL_DestroyRenderer(renderer);
+    SDL_DestroyWindow(window);
+
     /* We're done! */
     SDL_Quit();
     return(0);
Comment 2 Sam Lantinga 2017-09-12 04:23:18 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_image/rev/28967769bc2e