mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 22:58:13 +00:00
Fix delete crash in UI tests (and possibly in real life)
This commit is contained in:
parent
378903ca3b
commit
e3eaa693c2
1 changed files with 21 additions and 2 deletions
|
|
@ -27,13 +27,25 @@
|
|||
#import "Utils.h"
|
||||
|
||||
@implementation ChatTableViewController {
|
||||
@private
|
||||
MSList* data;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Lifecycle Functions
|
||||
|
||||
-(instancetype)init {
|
||||
self = super.init;
|
||||
if( self ){
|
||||
self->data = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if( data != nil ) {
|
||||
ms_list_free_with_data(data, chatTable_free_chatrooms);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - ViewController Functions
|
||||
|
||||
|
|
@ -44,6 +56,7 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRoom *elem){
|
||||
|
|
@ -85,7 +98,7 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo
|
|||
static void chatTable_free_chatrooms(void *data){
|
||||
LinphoneChatMessage* lastMsg = linphone_chat_room_get_user_data(data);
|
||||
if( lastMsg ){
|
||||
linphone_chat_message_unref(linphone_chat_room_get_user_data(data));
|
||||
linphone_chat_message_unref(lastMsg);
|
||||
linphone_chat_room_set_user_data(data, NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -152,8 +165,14 @@ static void chatTable_free_chatrooms(void *data){
|
|||
[tableView beginUpdates];
|
||||
|
||||
LinphoneChatRoom *chatRoom = (LinphoneChatRoom*)ms_list_nth_data(data, (int)[indexPath row]);
|
||||
LinphoneChatMessage* last_msg = linphone_chat_room_get_user_data(chatRoom);
|
||||
if( last_msg ){
|
||||
linphone_chat_message_unref(last_msg);
|
||||
linphone_chat_room_set_user_data(chatRoom, NULL);
|
||||
}
|
||||
linphone_chat_room_delete_history(chatRoom);
|
||||
linphone_chat_room_unref(chatRoom);
|
||||
data = ms_list_remove(data, chatRoom);
|
||||
|
||||
// will force a call to [self loadData]
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneTextReceived object:self];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue