diff options
| author | Ahmed El Khazari <ahmed.el.khazari@qt.io> | 2024-09-09 11:30:59 +0300 |
|---|---|---|
| committer | Ahmed El Khazari <ahmed.el.khazari@qt.io> | 2024-09-09 11:35:36 +0300 |
| commit | 913ccd992158f21b49d5cbd31f4ebce30871a2cf (patch) | |
| tree | ba8405e0f55cc0a1c547c898dcf138554a85e694 | |
| parent | 250b6e313cadacf2dfb0d4d16d1f4c61e5652de1 (diff) | |
| parent | 3f7ab586061d3e0c6aa9da97e4bb53417bb93395 (diff) | |
Merge branch and updated the licence
| -rw-r--r-- | sample-android/templates/initclass_preamble.kte | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/sample-android/templates/initclass_preamble.kte b/sample-android/templates/initclass_preamble.kte index 5d2dac2..a2f3cf8 100644 --- a/sample-android/templates/initclass_preamble.kte +++ b/sample-android/templates/initclass_preamble.kte @@ -21,25 +21,21 @@ @param jteData: JteData ${jteData.initClassPrefix} bool ${jteData.className}::initClazz(JNIEnv* env) { #define JENNY_CHECK_NULL(val) \ - do { \ - if ((val) == nullptr) { \ -@if (!jteData.environment.configurations.errorLoggerFunction.isNullOrBlank()) - ${jteData.environment.configurations.errorLoggerFunction}(env, "can't init ${jteData.className}::" #val); \ -@else - env->ExceptionDescribe(); \ -@endif - return false; \ - } \ - } while(false) +do { \ +if ((val) == nullptr) { \ +@if (!jteData.environment.configurations.errorLoggerFunction.isNullOrBlank()) ${jteData.environment.configurations.errorLoggerFunction}(env, "can't init ${jteData.className}::" #val); \@else env->ExceptionDescribe(); \@endif +return false; \ +} \ +} while(false) - auto& state = getClassInitState(); +auto& state = getClassInitState(); @if (jteData.environment.configurations.threadSafe) +if (!state.sInited) { +std::lock_guard<std::mutex> lg(state.sInitLock); + @endif if (!state.sInited) { - std::lock_guard<std::mutex> lg(state.sInitLock); -@endif - if (!state.sInited) { - auto clazz = env->FindClass(FULL_CLASS_NAME); - JENNY_CHECK_NULL(clazz); - state.sClazz = reinterpret_cast<jclass>(env->NewGlobalRef(clazz)); - env->DeleteLocalRef(clazz); - JENNY_CHECK_NULL(state.sClazz);
\ No newline at end of file + auto clazz = env->FindClass(FULL_CLASS_NAME); + JENNY_CHECK_NULL(clazz); + state.sClazz = reinterpret_cast<jclass>(env->NewGlobalRef(clazz)); + env->DeleteLocalRef(clazz); + JENNY_CHECK_NULL(state.sClazz);
\ No newline at end of file |
