summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/native/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/native/macosx')
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 919108db9..c04ba786e 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -336,6 +336,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0
(JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [CATransaction begin];
NSRect rect = NSMakeRect(x, y, width, height);
// Allocate the window
@@ -365,6 +366,7 @@ NS_ENDHANDLER
// [myView lockFocus];
// [myView unlockFocus];
+ [CATransaction commit];
[pool release];
return (jlong) ((intptr_t) myWindow);
@@ -379,9 +381,17 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0
(JNIEnv *env, jclass unused, jlong nsWindow)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSWindow* mWin = (NSWindow*) ((intptr_t) nsWindow);
+ [CATransaction begin];
+NS_DURING
+ NSWindow* mWin = (NSWindow*) ((intptr_t) nsWindow);
[mWin close]; // performs release!
+NS_HANDLER
+ // On killing or terminating the process [NSWindow _close], rarely
+ // throws an NSRangeException while ordering out menu items
+NS_ENDHANDLER
+
+ [CATransaction commit];
[pool release];
}
@@ -861,8 +871,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_Ge
NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer");
return 0;
}
- id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)dsi->platformInfo;
- return (jlong) ((intptr_t) surfaceLayers);
+ NSObject *surfaceLayersObj = (NSObject*) dsi->platformInfo;
+ [surfaceLayersObj retain]; // Pairs w/ Unset
+ DBG_PRINT("CALayer::GetJAWTSurfaceLayersHandle: surfaceLayers %p (refcnt %d)\n", surfaceLayersObj, (int)[surfaceLayersObj retainCount]);
+
+ id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)surfaceLayersObj;
+ return (jlong) (intptr_t) surfaceLayers;
}
/*
@@ -878,9 +892,11 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_Set
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)(intptr_t)jawtSurfaceLayersHandle;
+ NSObject *surfaceLayersObj = (NSObject*) (intptr_t) jawtSurfaceLayersHandle;
+ id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)surfaceLayersObj;
MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer;
DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: pre %p -> root %p (refcnt %d)\n", [surfaceLayers layer], layer, (int)[layer retainCount]);
+
[surfaceLayers setLayer: [layer retain]]; // Pairs w/ Unset
[CATransaction commit];
@@ -902,20 +918,26 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_Uns
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
- id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)(intptr_t)jawtSurfaceLayersHandle;
+ NSObject *surfaceLayersObj = (NSObject*) (intptr_t) jawtSurfaceLayersHandle;
+ id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)surfaceLayersObj;
+ DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.0: surfaceLayers %p (refcnt %d)\n", surfaceLayersObj, (int)[surfaceLayersObj retainCount]);
+
MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer;
- if(layer != [surfaceLayers layer]) {
- NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer);
- return;
+ if(NULL != layer) {
+ if(layer != [surfaceLayers layer]) {
+ NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer);
+ return;
+ }
+ DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.1: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]);
+ [layer release]; // Pairs w/ Set
+ [surfaceLayers setLayer: NULL]; // Pairs w/ Set
}
- DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.0: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]);
- [layer release]; // Pairs w/ Set
- [surfaceLayers setLayer: NULL];
+ [surfaceLayersObj release]; // Pairs w/ Get
[CATransaction commit];
[pool release];
- DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.X: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]);
+ DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.X\n");
}
@interface MainRunnable : NSObject