From 6d7b97c7a0acebf9b9179dfdc62749c8bbf2f125 Mon Sep 17 00:00:00 2001 From: ceylo Date: Sun, 4 Apr 2010 18:30:46 +0000 Subject: [PATCH] Fixed NSException raised when using Cocoa windows after the SFML window has been closed. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1482 4e206d99-4929-0410-ac5d-dfc041789085 --- src/SFML/Window/Cocoa/GLKit.mm | 39 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/SFML/Window/Cocoa/GLKit.mm b/src/SFML/Window/Cocoa/GLKit.mm index f19fa77f..fd990c10 100644 --- a/src/SFML/Window/Cocoa/GLKit.mm +++ b/src/SFML/Window/Cocoa/GLKit.mm @@ -549,25 +549,26 @@ [myWindow release]; myWindow = [aWindow retain]; - // Set the new observers - // We want to know when our window got the focus - [nc addObserver:self - selector:@selector(windowDidBecomeMain:) - name:NSWindowDidBecomeMainNotification - object:[self window]]; - - // We want to know when our window lost the focus - [nc addObserver:self - selector:@selector(windowDidResignMain:) - name:NSWindowDidResignMainNotification - object:[self window]]; - - // We want to know when the user closes the window - [nc addObserver:self - selector:@selector(windowWillClose:) - name:NSWindowWillCloseNotification - object:[self window]]; - + if (myWindow) { + // Set the new observers + // We want to know when our window got the focus + [nc addObserver:self + selector:@selector(windowDidBecomeMain:) + name:NSWindowDidBecomeMainNotification + object:[self window]]; + + // We want to know when our window lost the focus + [nc addObserver:self + selector:@selector(windowDidResignMain:) + name:NSWindowDidResignMainNotification + object:[self window]]; + + // We want to know when the user closes the window + [nc addObserver:self + selector:@selector(windowWillClose:) + name:NSWindowWillCloseNotification + object:[self window]]; + } } }