From 8432847288664ab29832f099692499c8e1198d32 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 29 Sep 2017 10:09:45 +0200 Subject: [PATCH] do not crash after destroying linphone core --- Classes/DialerView.m | 28 +++++++++++++++++++--------- Classes/HistoryDetailsView.m | 12 +++++++++++- Classes/HistoryListTableView.m | 14 ++++++++++++-- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/Classes/DialerView.m b/Classes/DialerView.m index 766085646..a22ea7415 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -192,17 +192,27 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)coreUpdateEvent:(NSNotification *)notif { - if (IPAD) { - if (linphone_core_video_display_enabled(LC) && linphone_core_video_preview_enabled(LC)) { - linphone_core_set_native_preview_window_id(LC, (__bridge void *)(_videoPreview)); - [_backgroundView setHidden:FALSE]; - [_videoCameraSwitch setHidden:FALSE]; - } else { - linphone_core_set_native_preview_window_id(LC, NULL); - [_backgroundView setHidden:TRUE]; - [_videoCameraSwitch setHidden:TRUE]; + @try { + if (IPAD) { + if (linphone_core_video_display_enabled(LC) && linphone_core_video_preview_enabled(LC)) { + linphone_core_set_native_preview_window_id(LC, (__bridge void *)(_videoPreview)); + [_backgroundView setHidden:FALSE]; + [_videoCameraSwitch setHidden:FALSE]; + } else { + linphone_core_set_native_preview_window_id(LC, NULL); + [_backgroundView setHidden:TRUE]; + [_videoCameraSwitch setHidden:TRUE]; + } } } + @catch (NSException *exception) { + if ([exception.name isEqualToString:@"LinphoneCoreException"]) { + LOGE(@"Core already destroyed"); + return; + } + LOGE(@"Uncaught exception : %@", exception.description); + abort(); + } } #pragma mark - Debug Functions diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m index b3360caee..d33dbc4d7 100644 --- a/Classes/HistoryDetailsView.m +++ b/Classes/HistoryDetailsView.m @@ -97,7 +97,17 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Event Functions - (void)coreUpdateEvent:(NSNotification *)notif { - [self update]; + @try { + [self update]; + } + @catch (NSException *exception) { + if ([exception.name isEqualToString:@"LinphoneCoreException"]) { + LOGE(@"Core already destroyed"); + return; + } + LOGE(@"Uncaught exception : %@", exception.description); + abort(); + } } - (void) deviceOrientationDidChange:(NSNotification*) notif { diff --git a/Classes/HistoryListTableView.m b/Classes/HistoryListTableView.m index 09cf99016..8bb004fe5 100644 --- a/Classes/HistoryListTableView.m +++ b/Classes/HistoryListTableView.m @@ -81,8 +81,18 @@ #pragma mark - Event Functions - (void)coreUpdateEvent:(NSNotification *)notif { - // Invalid all pointers - [self loadData]; + @try { + // Invalid all pointers + [self loadData]; + } + @catch (NSException *exception) { + if ([exception.name isEqualToString:@"LinphoneCoreException"]) { + LOGE(@"Core already destroyed"); + return; + } + LOGE(@"Uncaught exception : %@", exception.description); + abort(); + } } #pragma mark - Property Functions