diff options
author | Sven Gothel <[email protected]> | 2013-03-18 08:16:25 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-03-18 08:16:25 +0100 |
commit | 3f2da22cfb682d0eb4fedec98b088f95371f8ef4 (patch) | |
tree | 514b488c7d8461184dbda8b9166d511563992055 /src/nativewindow/native/NativewindowCommon.c | |
parent | ed911109d40e0fca3b2263a4617f35d475612549 (diff) |
NativeWindow OSXUtil RunOnMainThread: Use daemon attachment and do not detach; Add RunLater0(..)
Diffstat (limited to 'src/nativewindow/native/NativewindowCommon.c')
-rw-r--r-- | src/nativewindow/native/NativewindowCommon.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nativewindow/native/NativewindowCommon.c b/src/nativewindow/native/NativewindowCommon.c index d2fdd5d69..e909c0494 100644 --- a/src/nativewindow/native/NativewindowCommon.c +++ b/src/nativewindow/native/NativewindowCommon.c @@ -74,7 +74,7 @@ jchar* NativewindowCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str) return strChars; } -JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int * shallBeDetached) { +JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int asDaemon, int * shallBeDetached) { JNIEnv* curEnv = NULL; JNIEnv* newEnv = NULL; int envRes; @@ -83,7 +83,12 @@ JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int * envRes = (*jvmHandle)->GetEnv(jvmHandle, (void **) &curEnv, jvmVersion) ; if( JNI_EDETACHED == envRes ) { // detached thread - attach to JVM - if( JNI_OK != ( envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL) ) ) { + if( asDaemon ) { + envRes = (*jvmHandle)->AttachCurrentThreadAsDaemon(jvmHandle, (void**) &newEnv, NULL); + } else { + envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL); + } + if( JNI_OK != envRes ) { fprintf(stderr, "JNIEnv: can't attach thread: %d\n", envRes); return NULL; } |