diff --git a/modules/juce_core/native/juce_android_JNIHelpers.h b/modules/juce_core/native/juce_android_JNIHelpers.h index 9d58ae6714..8e8b07d3ad 100644 --- a/modules/juce_core/native/juce_android_JNIHelpers.h +++ b/modules/juce_core/native/juce_android_JNIHelpers.h @@ -362,6 +362,12 @@ private: extern ThreadLocalJNIEnvHolder threadLocalJNIEnvHolder; +struct AndroidThreadScope +{ + AndroidThreadScope() { threadLocalJNIEnvHolder.attach(); } + ~AndroidThreadScope() { threadLocalJNIEnvHolder.detach(); } +}; + //============================================================================== #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \ METHOD (createNewView, "createNewView", "(ZJ)L" JUCE_ANDROID_ACTIVITY_CLASSPATH "$ComponentPeerView;") \ diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index 7bdbc55baf..05ed874c76 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -837,12 +837,6 @@ extern "C" void* threadEntryProc (void* userData) JUCE_AUTORELEASEPOOL { #if JUCE_ANDROID - struct AndroidThreadScope - { - AndroidThreadScope() { threadLocalJNIEnvHolder.attach(); } - ~AndroidThreadScope() { threadLocalJNIEnvHolder.detach(); } - }; - const AndroidThreadScope androidEnv; #endif @@ -1184,7 +1178,9 @@ private: static void* timerThread (void* param) { - #if ! JUCE_ANDROID + #if JUCE_ANDROID + const AndroidThreadScope androidEnv; + #else int dummy; pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &dummy); #endif