forked from mirrors/linphone-iphone
fix chatroominfoview crash by reconfiguring the chatroom after entering background puis foreground
This commit is contained in:
parent
640cb70ebf
commit
ed964d8736
4 changed files with 32 additions and 18 deletions
|
|
@ -34,6 +34,7 @@
|
|||
@property(nonatomic) NSString *oldSubject;
|
||||
@property(nonatomic) LinphoneChatRoom *room;
|
||||
@property(nonatomic) LinphoneChatRoomCbs *chatRoomCbs;
|
||||
@property(nonatomic) const char *peerAddress;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIIconButton *nextButton;
|
||||
@property (weak, nonatomic) IBOutlet UIRoundBorderedButton *quitButton;
|
||||
|
|
@ -49,6 +50,4 @@
|
|||
- (IBAction)onBackClick:(id)sender;
|
||||
- (IBAction)onQuitClick:(id)sender;
|
||||
|
||||
- (void)removeCallbacks;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -83,12 +83,30 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
_oldContacts = [[NSMutableArray alloc] init];
|
||||
_room = NULL;
|
||||
_chatRoomCbs = NULL;
|
||||
_peerAddress = NULL;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
_waitView.hidden = YES;
|
||||
|
||||
[self configure];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self
|
||||
selector:@selector(onLinphoneCoreReady:)
|
||||
name:kLinphoneGlobalStateUpdate
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self];
|
||||
if (!_room || !_chatRoomCbs)
|
||||
return;
|
||||
|
||||
linphone_chat_room_remove_callbacks(_room, _chatRoomCbs);
|
||||
_chatRoomCbs = NULL;
|
||||
}
|
||||
|
||||
- (void)configure {
|
||||
if (_create)
|
||||
_room = NULL;
|
||||
|
||||
|
|
@ -131,20 +149,20 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[_tableView reloadData];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[self removeCallbacks];
|
||||
}
|
||||
|
||||
- (void)removeCallbacks {
|
||||
if (!_room || !_chatRoomCbs)
|
||||
return;
|
||||
|
||||
linphone_chat_room_remove_callbacks(_room, _chatRoomCbs);
|
||||
_chatRoomCbs = NULL;
|
||||
}
|
||||
|
||||
#pragma mark - next functions
|
||||
|
||||
- (void)onLinphoneCoreReady:(NSNotification *)notif {
|
||||
if ((LinphoneGlobalState)[[[notif userInfo] valueForKey:@"state"] integerValue] == LinphoneGlobalOn) {
|
||||
if (!_create && _peerAddress) {
|
||||
LinphoneAddress *peerAddr = linphone_core_create_address([LinphoneManager getLc], _peerAddress);
|
||||
if (peerAddr) {
|
||||
_room = linphone_core_get_chat_room([LinphoneManager getLc], peerAddr);
|
||||
}
|
||||
[self configure];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onCreate {
|
||||
bctbx_list_t *addresses = NULL;
|
||||
for (NSString *addr in _contacts) {
|
||||
|
|
|
|||
|
|
@ -888,6 +888,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
view.oldAdmins = [admins mutableCopy];
|
||||
view.oldSubject = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT];
|
||||
view.room = _chatRoom;
|
||||
view.peerAddress = _peerAddress;
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,10 +69,6 @@
|
|||
[view removeCallBacks];
|
||||
[view.tableController setChatRoom:NULL];
|
||||
[view setChatRoom:NULL];
|
||||
} else if (PhoneMainView.instance.currentView == ChatConversationInfoView.compositeViewDescription) {
|
||||
ChatConversationInfoView *view = VIEW(ChatConversationInfoView);
|
||||
[view removeCallbacks];
|
||||
[view setRoom:NULL];
|
||||
} else if (PhoneMainView.instance.currentView == RecordingsListView.compositeViewDescription || PhoneMainView.instance.currentView == DevicesListView.compositeViewDescription) {
|
||||
// To avoid crash
|
||||
[PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue