From 78807b9e1a2b8e204e01a1de53a31207bffcf306 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Wed, 15 Oct 2014 17:07:14 +0200 Subject: [PATCH] Fix crash when coming back from background when LinphoneCore has been destroyed --- Classes/LinphoneManager.m | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index e08159ef3..293a6389a 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1868,17 +1868,19 @@ static void audioRouteChangeListenerCallback ( } + (int)unreadMessageCount { - int count = 0; - MSList* rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]); - MSList* item = rooms; - while (item) { - LinphoneChatRoom* room = (LinphoneChatRoom*)item->data; - if( room ){ - count += linphone_chat_room_get_unread_messages_count(room); - } - item = item->next; - } - return count; + int count = 0; + if( [LinphoneManager isLcReady] ){ + MSList* rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]); + MSList* item = rooms; + while (item) { + LinphoneChatRoom* room = (LinphoneChatRoom*)item->data; + if( room ){ + count += linphone_chat_room_get_unread_messages_count(room); + } + item = item->next; + } + } + return count; } + (BOOL)copyFile:(NSString*)src destination:(NSString*)dst override:(BOOL)override {