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 1605

Summary: SDL_DestroyWindow causes erroneous error message
Product: SDL Reporter: matto <matthewharveys>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: x86_64   
OS: Linux   

Description matto 2012-09-21 00:58:09 UTC
In SDL_DestroyWindow, there is a conditional call to SDL_GL_MakeCurrent(NULL,NULL). This function has within it the CHECK_WINDOW_MAGIC macro, which outputs the error "Invalid window" and returns if the "window" parameter to the macro is null. While writing an application, I found that my code continuously output this error, but nothing would go wrong.
I am using XUbuntu 12.04 and Ubuntu 12.04. I don't know enough to tell whether the function is wrong or the function call is wrong, but the behaviour is wrong (the error output without any real error occurring). 
This is on the HG 2.0 repo, updated a couple of hours ago.

I'm pretty sure this happens whenever I make the following call:
SDL_Init(SDL_INIT_VIDEO)

The stack trace would look something like this:

SDL_Init(SDL_INIT_VIDEO);
SDL_InitSubsystem(SDL_INIT_VIDEO);
SDL_VideoInit(NULL);
ShouldUseTextureFramebuffer();
SDL_GL_MakeCurrent(NULL,NULL);
CHECK_WINDOW_MAGIC
Error is created

If the CHECK_WINDOW_MAGIC is simply removed, it results in a Seg Fault. I figure that the MakeCurrent function has to be modified to work properly with NULL values, but I'm not sure about that.
Comment 1 Sam Lantinga 2012-09-28 04:03:38 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/d7cb947898d7