From 160b81a6e04a9c3a5ee29ea653cb0aa52165160d Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 27 Jul 2016 10:37:26 +0200 Subject: [PATCH] misc: avoid some crashes --- Classes/ContactDetailsView.m | 2 +- Classes/LinphoneManager.m | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 914dbbdf8..b303652e3 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -163,8 +163,8 @@ } - (void)viewWillDisappear:(BOOL)animated { - [super viewWillDisappear:animated]; [_tableController.tableView removeObserver:self forKeyPath:@"contentSize"]; + [super viewWillDisappear:animated]; } #pragma mark - UICompositeViewDelegate Functions diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 2e07db501..737a2bd86 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1410,16 +1410,20 @@ static LinphoneCoreVTable linphonec_vtable = { /*DETECT cameras*/ _frontCamId = _backCamId = nil; char **camlist = (char **)linphone_core_get_video_devices(theLinphoneCore); - for (char *cam = *camlist; *camlist != NULL; cam = *++camlist) { - if (strcmp(FRONT_CAM_NAME, cam) == 0) { - _frontCamId = cam; - // great set default cam to front - LOGI(@"Setting default camera [%s]", _frontCamId); - linphone_core_set_video_device(theLinphoneCore, _frontCamId); - } - if (strcmp(BACK_CAM_NAME, cam) == 0) { - _backCamId = cam; + if (camlist) { + for (char *cam = *camlist; *camlist != NULL; cam = *++camlist) { + if (strcmp(FRONT_CAM_NAME, cam) == 0) { + _frontCamId = cam; + // great set default cam to front + LOGI(@"Setting default camera [%s]", _frontCamId); + linphone_core_set_video_device(theLinphoneCore, _frontCamId); + } + if (strcmp(BACK_CAM_NAME, cam) == 0) { + _backCamId = cam; + } } + } else { + LOGW(@"No camera detected!"); } if (![LinphoneManager isNotIphone3G]) { @@ -2089,10 +2093,14 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { } _pushNotificationToken = apushNotificationToken; - const MSList *proxies = linphone_core_get_proxy_config_list(LC); - while (proxies) { - [self configurePushTokenForProxyConfig:proxies->data]; - proxies = proxies->next; + @try { + const MSList *proxies = linphone_core_get_proxy_config_list(LC); + while (proxies) { + [self configurePushTokenForProxyConfig:proxies->data]; + proxies = proxies->next; + } + } @catch (NSException* e) { + LOGW(@"%s: linphone core not ready yet, ignoring push token", __FUNCTION__); } }