Fix leakage of JNI object references
Fixes https://github.com/godotengine/godot/issues/87548
This commit is contained in:
@ -239,6 +239,17 @@ public:
|
||||
JNISingleton() {
|
||||
#ifdef ANDROID_ENABLED
|
||||
instance = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
~JNISingleton() {
|
||||
#ifdef ANDROID_ENABLED
|
||||
if (instance) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
ERR_FAIL_NULL(env);
|
||||
|
||||
env->DeleteGlobalRef(instance);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user