Commit 539f7b0f authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Do not set the same listener twice and clear the previous one if it exists in Java wrapper

parent 373dafd9
...@@ -366,7 +366,17 @@ void Java_{{jniPackage}}{{className}}Impl_setListener(JNIEnv* env, jobject thiz, ...@@ -366,7 +366,17 @@ void Java_{{jniPackage}}{{className}}Impl_setListener(JNIEnv* env, jobject thiz,
env->DeleteGlobalRef(listener); env->DeleteGlobalRef(listener);
} }
} else { } else {
jobject listener = env->NewGlobalRef(jlistener); jobject listener = (jobject) {{cPrefix}}_cbs_get_user_data(cbs);
if (listener == NULL) {
listener = env->NewGlobalRef(jlistener);
} else {
if (env->IsSameObject(listener, jlistener)) {
return;
} else {
env->DeleteGlobalRef(listener);
listener = env->NewGlobalRef(jlistener);
}
}
{{cPrefix}}_cbs_set_user_data(cbs, listener); {{cPrefix}}_cbs_set_user_data(cbs, listener);
{{#callbacksList}} {{#callbacksList}}
{{cPrefix}}_cbs_set_{{callback}}(cbs, {{callbackName}}); {{cPrefix}}_cbs_set_{{callback}}(cbs, {{callbackName}});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment