diff options
author | Sven Gothel <[email protected]> | 2011-11-18 07:14:41 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-11-18 07:14:41 +0100 |
commit | d644e9321dceeecdd94a1797e25e6e356d957c23 (patch) | |
tree | 95705d387b3a4e54078e163587e846dd04f0aa8d /src/nativewindow/native/macosx | |
parent | e5e3a035237294e69e86d8dcb4cce55049eedac7 (diff) |
Fix OS X JAWT SIGSEGV @ NEWT Window creation ; Reloc AttachJAWTSurfaceLayer() OSXUtil -> MacOSXJAWTWindow
Threading/sync issue when creating a NEWT window, which issues a Java callback from native code (positionChanged()).
The latter requires a location validation w/ getLocationOnScreen() involved.
Hence getLocationOnScreen() shall not lock the JAWT native resources,
since it may not be ready yet (-> threading/sync issue).
Diffstat (limited to 'src/nativewindow/native/macosx')
-rw-r--r-- | src/nativewindow/native/macosx/OSXmisc.m | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 45ff1bd4c..d7a2feff3 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -35,6 +35,7 @@ #include "NativewindowCommon.h" #include "jogamp_nativewindow_macosx_OSXUtil.h" +#include "jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow.h" #include <jawt_md.h> #import <JavaNativeFoundation.h> @@ -323,30 +324,6 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 JNF_COCOA_EXIT(env); } -/* - * Class: Java_jogamp_nativewindow_macosx_OSXUtil - * Method: attachJAWTSurfaceLayer - * Signature: (JJ)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AttachJAWTSurfaceLayer0 - (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) -{ - JNF_COCOA_ENTER(env); - JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); - if (NULL == dsi) { - NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); - return JNI_FALSE; - } - CALayer* layer = (CALayer*) (intptr_t) caLayer; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)dsi->platformInfo; - DBG_PRINT("CALayer::attachJAWTSurfaceLayer: %p -> %p\n", surfaceLayers.layer, layer); - surfaceLayers.layer = [layer autorelease]; - }]; - JNF_COCOA_EXIT(env); - return JNI_TRUE; -} - @interface MainRunnable : NSObject { @@ -432,3 +409,27 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_IsMainThread0 return ( [NSThread isMainThread] == YES ) ? JNI_TRUE : JNI_FALSE ; } +/* + * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow + * Method: AttachJAWTSurfaceLayer + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_AttachJAWTSurfaceLayer0 + (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) +{ + JNF_COCOA_ENTER(env); + JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); + if (NULL == dsi) { + NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); + return JNI_FALSE; + } + CALayer* layer = (CALayer*) (intptr_t) caLayer; + [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + id <JAWT_SurfaceLayers> surfaceLayers = (id <JAWT_SurfaceLayers>)dsi->platformInfo; + DBG_PRINT("CALayer::attachJAWTSurfaceLayer: %p -> %p\n", surfaceLayers.layer, layer); + surfaceLayers.layer = [layer autorelease]; + }]; + JNF_COCOA_EXIT(env); + return JNI_TRUE; +} + |