diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index 926527286..e53b3227d 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -40,17 +40,9 @@ self.tableView.accessibilityIdentifier = @"ChatRoom list"; } -- (void)viewWillDisappear:(BOOL)animated { - [self clearEventList]; -} - #pragma mark - - (void)clearEventList { - for (NSValue *value in eventList) { - LinphoneEventLog *event = (LinphoneEventLog *)[value pointerValue]; - linphone_event_log_unref(event); - } [eventList removeAllObjects]; } @@ -59,18 +51,16 @@ return; [self clearEventList]; LinphoneChatRoomCapabilitiesMask capabilities = linphone_chat_room_get_capabilities(_chatRoom); - bctbx_list_t *chatRoomEvents = (capabilities & LinphoneChatRoomCapabilitiesOneToOne) + bctbx_list_t *chatRoomEvents = (capabilities & LinphoneChatRoomCapabilitiesOneToOne) ? linphone_chat_room_get_history_message_events(_chatRoom, 0) : linphone_chat_room_get_history_events(_chatRoom, 0); - bctbx_list_t *chatRoomEventsHead = chatRoomEvents; eventList = [[NSMutableArray alloc] initWithCapacity:bctbx_list_size(chatRoomEvents)]; while (chatRoomEvents) { LinphoneEventLog *event = (LinphoneEventLog *)chatRoomEvents->data; - [eventList addObject:[NSValue valueWithPointer:event]]; + [eventList addObject:[NSValue valueWithPointer:linphone_event_log_ref(event)]]; chatRoomEvents = chatRoomEvents->next; } - bctbx_list_free(chatRoomEventsHead); for (FileTransferDelegate *ftd in [LinphoneManager.instance fileTransferDelegates]) { const LinphoneAddress *ftd_peer = @@ -90,7 +80,7 @@ } - (void)addEventEntry:(LinphoneEventLog *)event { - [eventList addObject:[NSValue valueWithPointer:event]]; + [eventList addObject:[NSValue valueWithPointer:linphone_event_log_ref(event)]]; int pos = (int)eventList.count - 1; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:pos inSection:0];