add release methods for friends and friend list, so that the core can properly shutdown without leaving references.

This commit is contained in:
Simon Morlat 2016-01-05 21:14:18 +01:00
parent 1a7bb84633
commit e4d97e2a51
4 changed files with 24 additions and 3 deletions

View file

@ -265,12 +265,16 @@ void linphone_friend_close_subscriptions(LinphoneFriend *lf){
lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc)sal_op_release);
}
static void _linphone_friend_destroy(LinphoneFriend *lf){
static void _linphone_friend_release_ops(LinphoneFriend *lf){
lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc) sal_op_release);
if (lf->outsub){
sal_op_release(lf->outsub);
lf->outsub=NULL;
}
}
static void _linphone_friend_destroy(LinphoneFriend *lf){
_linphone_friend_release_ops(lf);
if (lf->presence != NULL) linphone_presence_model_unref(lf->presence);
if (lf->uri!=NULL) linphone_address_destroy(lf->uri);
if (lf->info!=NULL) buddy_info_free(lf->info);
@ -712,6 +716,13 @@ void linphone_friend_destroy(LinphoneFriend *lf) {
linphone_friend_unref(lf);
}
/*drops all references to the core and unref*/
void _linphone_friend_release(LinphoneFriend *lf){
lf->lc = NULL;
_linphone_friend_release_ops(lf);
linphone_friend_unref(lf);
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriend);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriend, belle_sip_object_t,

View file

@ -250,6 +250,14 @@ LinphoneFriendList * linphone_friend_list_ref(LinphoneFriendList *list) {
return list;
}
void _linphone_friend_list_release(LinphoneFriendList *list){
/*drops all references to core and unref*/
list->lc = NULL;
if (list->event != NULL) linphone_event_unref(list->event);
list->friends = ms_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release);
belle_sip_object_unref(list);
}
void linphone_friend_list_unref(LinphoneFriendList *list) {
belle_sip_object_unref(list);
}

View file

@ -6352,10 +6352,10 @@ static void codecs_config_uninit(LinphoneCore *lc)
void ui_config_uninit(LinphoneCore* lc)
{
ms_message("Destroying friends.");
linphone_friend_list_unref(lc->friendlist);
_linphone_friend_list_release(lc->friendlist);
lc->friendlist = NULL;
if (lc->subscribers){
lc->subscribers = ms_list_free_with_data(lc->subscribers, (void (*)(void *))linphone_friend_unref);
lc->subscribers = ms_list_free_with_data(lc->subscribers, (void (*)(void *))_linphone_friend_release);
}
if (lc->presence_model) {
linphone_presence_model_unref(lc->presence_model);

View file

@ -393,8 +393,10 @@ const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphonePro
void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list);
void linphone_friend_list_notify_presence_received(LinphoneFriendList *list, LinphoneEvent *lev, const LinphoneContent *body);
void _linphone_friend_list_release(LinphoneFriendList *list);
void linphone_friend_invalidate_subscription(LinphoneFriend *lf);
void linphone_friend_close_subscriptions(LinphoneFriend *lf);
void _linphone_friend_release(LinphoneFriend *lf);
void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *cfg, bool_t only_when_registered);
void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence);
void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op);