From f04db9985ccc85d6c48210e4abbd07e6b0ccad75 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 9 Feb 2016 10:23:32 +0100 Subject: [PATCH] CallOutgoing: fix crash on iPad --- Classes/CallOutgoingView.m | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Classes/CallOutgoingView.m b/Classes/CallOutgoingView.m index 7bcf73938..00a891c3f 100644 --- a/Classes/CallOutgoingView.m +++ b/Classes/CallOutgoingView.m @@ -59,16 +59,16 @@ static UICompositeViewDescription *compositeDescription = nil; LinphoneCall *call = linphone_core_get_current_call(LC); if (!call) { - [PhoneMainView.instance popCurrentView]; - } else { - const LinphoneAddress *addr = linphone_call_get_remote_address(call); - [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; - char *uri = linphone_address_as_string_uri_only(addr); - _addressLabel.text = [NSString stringWithUTF8String:uri]; - ms_free(uri); - [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:NO] bordered:YES withRoundedRadius:YES]; + return; } + const LinphoneAddress *addr = linphone_call_get_remote_address(call); + [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; + char *uri = linphone_address_as_string_uri_only(addr); + _addressLabel.text = [NSString stringWithUTF8String:uri]; + ms_free(uri); + [_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:NO] bordered:YES withRoundedRadius:YES]; + [self hideSpeaker:LinphoneManager.instance.bluetoothAvailable]; [_speakerButton update]; @@ -76,6 +76,17 @@ static UICompositeViewDescription *compositeDescription = nil; [_routesButton update]; } +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + // if there is no call (for whatever reason), we must wait viewDidAppear method + // before popping current view, because UICompositeView cannot handle view change + // directly in viewWillAppear (this would lead to crash in deallocated memory - easily + // reproductible on iPad mini). + if (!linphone_core_get_current_call(LC)) { + [PhoneMainView.instance popCurrentView]; + } +} + - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [NSNotificationCenter.defaultCenter removeObserver:self];