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 718

Summary: QZ_UnsetVideoMode don't release window.
Product: SDL Reporter: Denis Maltsev <maltsev-da>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED WONTFIX QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: ewmailing, sezeroz
Version: 1.2.13Keywords: target-1.2.14
Hardware: PowerPC   
OS: Mac OS X (All)   

Description Denis Maltsev 2009-03-17 21:30:16 UTC
For releasing window (qz_window) using this code (QZ_UnsetVideoMode): 
[ qz_window close ]; /* includes release because [qz_window isReleasedWhenClosed] */ 
I don't find isReleasedWhenClosed anywhere in SDL project. 
Looks like old window is still in memory. Just put breakpoint in 
- (void)appDidHide:(NSNotification*)note 
and try to hide window after recreating it (in OpenGL mode for example). 
It catch two times. 

I replace old code 
[ qz_window close ]; 
on this code   
[ qz_window release ]; 
in QZ_UnsetVideoMode and all works fine.
Comment 1 Ryan C. Gordon 2009-09-13 16:33:14 UTC
Tagging this bug with "target-1.2.14" so we can try to resolve it for SDL 1.2.14.

Please note that we may choose to resolve it as WONTFIX. This tag is largely so we have a comprehensive wishlist of bugs to examine for 1.2.14 (and so we can close bugs that we'll never fix, rather than have them live forever in Bugzilla).

--ryan.
Comment 2 Eric wing 2009-09-21 03:11:46 UTC
I don't know the actual code well enough to say if this is a bug or now, but it sounds like the intent was to set a flag on NSWindow to automatically release when closed.

setReleasedWhenClosed and isReleasedWhenClosed are methods built into NSWindow. We don't define them. If setReleased

The report is claiming it is leaking, but I don't think the test is correct. I'm not convinced hiding the window is the same as closing it. (The Apple documentation talks about the inverse, i.e. releasedWhenClosed=0 will hide the window rather than releasing it).

I verified that setReleasedWhenClosed is the default value which is why we don't need to set it. (I added a printf to the code to verify.)

The documentation does warn that setReleasedWhenClosed has no effect when the window is owned by NSWindowController, but I don't see that class in use in the code base.

My overall feeling is that there is no bug here due to this. But I do recall older complaints about memory leaks, possibly related to the window code in general, but nobody ever found it. If this is a bug though, I think need a better test than appDidHide to verify it. (It could be something else is retaining the window so the window is not being released.)
Comment 3 Sam Lantinga 2009-09-24 00:36:09 UTC
It's risky to mess with the Quartz code at this point.  Please take a look at SDL 1.3 and see if there's a similar issue there.
http://www.libsdl.org/tmp/SDL-1.3.zip

Thanks!