Commit b6f74357 authored by Simon Morlat's avatar Simon Morlat

delete JNI weak refs when the java object (LinphoneFriend or LinphoneChatMessage) is finalized.

This will avoid a periodic weak ref overflow.
parent 9adce331
......@@ -4191,7 +4191,11 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_finalize(JNIEnv* env
,jobject thiz
,jlong ptr) {
LinphoneFriend *lfriend=(LinphoneFriend*)ptr;
jobject wref = (jobject)linphone_friend_get_user_data(lfriend);
linphone_friend_set_user_data(lfriend,NULL);
if (wref){
env->DeleteWeakGlobalRef(wref);
}
linphone_friend_unref(lfriend);
}
......@@ -4727,7 +4731,11 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setListener(JNIEn
extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_unref(JNIEnv* env
,jobject thiz
,jlong ptr) {
jobject wref = (jobject)linphone_chat_message_get_user_data((LinphoneChatMessage*)ptr);
linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr, NULL);
if (wref){
env->DeleteWeakGlobalRef(wref);
}
linphone_chat_message_unref((LinphoneChatMessage*)ptr);
}
......
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