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 5067 - SDL_Quit does not call VideoQuit when video was auto-initialized via SDL_CreateWindow
Summary: SDL_Quit does not call VideoQuit when video was auto-initialized via SDL_Crea...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Other
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.14
Depends on:
Blocks:
 
Reported: 2020-03-30 04:37 UTC by Jay Petacat
Modified: 2020-06-27 01:41 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 Jay Petacat 2020-03-30 04:37:05 UTC
When exiting testspriteminimal, my driver's VideoQuit function is not executed, even if I call SDL_Quit in the test's quit function (is it intentionally absent?). As far as I can tell, it is because the video subsystem's reference count is zero and SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO) returns false.

My expectation is that SDL_Quit should know what to cleanup in this situation. If a maintainer affirms this, I will attempt to develop a patch.

Tangentially, if omitting SDL_Quit is a supported scenario, how shall I ensure my VideoQuit gets executed? atexit?
Comment 1 Ryan C. Gordon 2020-06-27 01:41:12 UTC
(In reply to Jay Petacat from comment #0)
> When exiting testspriteminimal, my driver's VideoQuit function is not
> executed, even if I call SDL_Quit in the test's quit function (is it
> intentionally absent?).

It is not intentionally absent, and I have now fixed that in https://hg.libsdl.org/SDL/rev/84dc2aca3b52

> My expectation is that SDL_Quit should know what to cleanup in this
> situation. If a maintainer affirms this, I will attempt to develop a patch.

You are correct, I think this is an oversight because most things call SDL_Init() explicitly (the attempt to recover by calling SDL_VideoInit implicitly is a leftover from SDL 1.2, and we should probably remove this behavior for SDL 2.1).

> Tangentially, if omitting SDL_Quit is a supported scenario, how shall I
> ensure my VideoQuit gets executed? atexit?

It's not a supported scenario, it was just a mistake in testspriteminimal, I assume it was deleted when cutting down testsprite2.c to not use the test framework.

Your diagnosis was correct, and I've now corrected the init call in https://hg.libsdl.org/SDL/rev/22ef6c87d061

Thanks!

--ryan.