[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53244] trunk/blender/intern/ghost/intern/ GHOST_WindowCocoa.mm: Fix #33644: rendering to a new window and then closing it would not completely

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Dec 21 12:56:05 CET 2012


Revision: 53244
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53244
Author:   blendix
Date:     2012-12-21 11:56:02 +0000 (Fri, 21 Dec 2012)
Log Message:
-----------
Fix #33644: rendering to a new window and then closing it would not completely
remove it, but still stick around listed in the Window menu.

Fixed by removing the setReleasedWhenClosed:NO hack and using the proper cocoa
window delegate mechanism.

Modified Paths:
--------------
    trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm

Modified: trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm	2012-12-21 11:31:59 UTC (rev 53243)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowCocoa.mm	2012-12-21 11:56:02 UTC (rev 53244)
@@ -67,13 +67,13 @@
 }
 
 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
-- (void)windowWillClose:(NSNotification *)notification;
 - (void)windowDidBecomeKey:(NSNotification *)notification;
 - (void)windowDidResignKey:(NSNotification *)notification;
 - (void)windowDidExpose:(NSNotification *)notification;
 - (void)windowDidResize:(NSNotification *)notification;
 - (void)windowDidMove:(NSNotification *)notification;
 - (void)windowWillMove:(NSNotification *)notification;
+- (BOOL)windowShouldClose:(id)sender;	
 @end
 
 @implementation CocoaWindowDelegate : NSObject
@@ -83,11 +83,6 @@
 	associatedWindow = winCocoa;
 }
 
-- (void)windowWillClose:(NSNotification *)notification
-{
-	systemCocoa->handleWindowEvent(GHOST_kEventWindowClose, associatedWindow);
-}
-
 - (void)windowDidBecomeKey:(NSNotification *)notification
 {
 	systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow);
@@ -132,6 +127,14 @@
 		wm_draw_update(ghostC);
 	}*/
 }
+
+- (BOOL)windowShouldClose:(id)sender;
+{
+	//Let Blender close the window rather than closing immediately
+	systemCocoa->handleWindowEvent(GHOST_kEventWindowClose, associatedWindow);
+	return false;
+}
+
 @end
 
 #pragma mark NSWindow subclass
@@ -571,8 +574,6 @@
 	[m_window setContentView:m_openGLView];
 	[m_window setInitialFirstResponder:m_openGLView];
 	
-	[m_window setReleasedWhenClosed:NO]; //To avoid bad pointer exception in case of user closing the window
-	
 	[m_window makeKeyAndOrderFront:nil];
 	
 	setDrawingContextType(type);
@@ -616,11 +617,6 @@
 	[m_openGLView release];
 	
 	if (m_window) {
-		// previously we called [m_window release], but on 10.8 this does not
-		// remove the window from [NSApp orderedWindows] and perhaps other
-		// places, leading to crashes. so instead we set setReleasedWhenClosed
-		// back to YES right before closing
-		[m_window setReleasedWhenClosed:YES];
 		[m_window close];
 	}
 	
@@ -955,7 +951,6 @@
 				//Copy current window parameters
 				[tmpWindow setTitle:[m_window title]];
 				[tmpWindow setRepresentedFilename:[m_window representedFilename]];
-				[tmpWindow setReleasedWhenClosed:NO];
 				[tmpWindow setAcceptsMouseMovedEvents:YES];
 				[tmpWindow setDelegate:[m_window delegate]];
 				[tmpWindow setSystemAndWindowCocoa:[m_window systemCocoa] windowCocoa:this];
@@ -1013,7 +1008,6 @@
 				//Copy current window parameters
 				[tmpWindow setTitle:[m_window title]];
 				[tmpWindow setRepresentedFilename:[m_window representedFilename]];
-				[tmpWindow setReleasedWhenClosed:NO];
 				[tmpWindow setAcceptsMouseMovedEvents:YES];
 				[tmpWindow setDelegate:[m_window delegate]];
 				[tmpWindow setSystemAndWindowCocoa:[m_window systemCocoa] windowCocoa:this];




More information about the Bf-blender-cvs mailing list