diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-22 12:52:16 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-22 12:52:16 +0200 |
commit | 8c474ddd4999883749b987b2d4b4c70f00ebd94d (patch) | |
tree | c6602732cad5bf09c73b991b6ee8dc9548df924c /platform/android/api/jni_singleton.h | |
parent | 4b6629978e8d1be15c5e3bc74db55900fa40f52e (diff) | |
parent | f291a4ed3a64dd95bf8136f352e5d0554ada4a7c (diff) | |
download | redot-engine-8c474ddd4999883749b987b2d4b4c70f00ebd94d.tar.gz |
Merge pull request #90710 from m4gr3d/fix_jstring_leaks
Fix leakage of JNI object references
Diffstat (limited to 'platform/android/api/jni_singleton.h')
-rw-r--r-- | platform/android/api/jni_singleton.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/platform/android/api/jni_singleton.h b/platform/android/api/jni_singleton.h index a2d1c08168..5b30c392e7 100644 --- a/platform/android/api/jni_singleton.h +++ b/platform/android/api/jni_singleton.h @@ -241,6 +241,17 @@ public: instance = nullptr; #endif } + + ~JNISingleton() { +#ifdef ANDROID_ENABLED + if (instance) { + JNIEnv *env = get_jni_env(); + ERR_FAIL_NULL(env); + + env->DeleteGlobalRef(instance); + } +#endif + } }; #endif // JNI_SINGLETON_H |