diff options
author | Sven Gothel <[email protected]> | 2013-11-01 01:25:32 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-11-01 01:25:32 +0100 |
commit | 85878162940067b39b17c71878446dff0759040d (patch) | |
tree | e63bd4eb2a20f06fd306ba01c8e59e86a211c6db /src/newt/native/MacWindow.m | |
parent | cc57413180edc4e5102f6729ccca6c4695d93e42 (diff) |
Bug 882 - Crash on OSX when closing NEWT window - Fix: Release NewtMacWindow manually in close0()
Release NewtMacWindow manually in close0()
- Mark [NewtMacWindow setReleasedWhenClosed: NO] in init0(..)
- Release NewtMacWindow manually in close0(..)
Check pointer args in close0(..)
Diffstat (limited to 'src/newt/native/MacWindow.m')
-rw-r--r-- | src/newt/native/MacWindow.m | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index f8988cf15..f0ed170f0 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -716,8 +716,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 rectWin = NSMakeRect(x, y, w, h); } - [myWindow setReleasedWhenClosed: YES]; // default + [myWindow setReleasedWhenClosed: NO]; // We control NSWindow destruction! [myWindow setPreservesContentDuringLiveResize: NO]; +NS_DURING + if ( [myWindow respondsToSelector:@selector(setRestorable:)] ) { + // Available >= 10.7 - Removes restauration 'feature', really close + [myWindow setRestorable: NO]; + } +NS_HANDLER +NS_ENDHANDLER NSObject* nsParentObj = (NSObject*) ((intptr_t) parent); NSWindow* parentWindow = NULL; @@ -857,8 +864,19 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); + if( NULL == mWin ) { + DBG_PRINT( "windowClose.0 - NULL NEWT win - abort\n"); + return; + } + BOOL isNSWin = [mWin isKindOfClass:[NSWindow class]]; + BOOL isNewtWin = [mWin isKindOfClass:[NewtMacWindow class]]; + NSWindow *pWin = [mWin parentWindow]; + DBG_PRINT( "windowClose.0 - %p [isNSWindow %d, isNewtWin %d], parent %p\n", mWin, isNSWin, isNewtWin, pWin); + if( !isNewtWin ) { + DBG_PRINT( "windowClose.0 - Not a NEWT win - abort\n"); + return; + } NewtView* mView = (NewtView *)[mWin contentView]; - NSWindow* pWin = [mWin parentWindow]; BOOL destroyNotifySent, isNSView, isNewtView; if( NULL != mView ) { isNSView = [mView isKindOfClass:[NSView class]]; @@ -905,11 +923,7 @@ NS_ENDHANDLER DBG_PRINT( "windowClose.1 - %p view %p, parent %p\n", mWin, mView, pWin); - // Only release window, if release is not yet in process. - // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. - if(!destroyNotifySent) { - [mWin release]; - } + [mWin release]; DBG_PRINT( "windowClose.Xp\n"); |