From bd0b56276aaa6068dbd4d5c6fea32f4ec68ffb34 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 10 Feb 2016 15:05:19 +0100 Subject: [PATCH] Dialer: add try/catch around self destruct code --- .gitignore | 1 + Classes/DialerView.m | 36 ++++++++++++++++++++++-------------- Resources/linphonerc-factory | 1 + 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 20dcb5af7..10fd37fe5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ submodules/tunnel submodules/binaries/dummy-*.a linphone-iphone.ipa TutorialHellowWorld/hello-world.xcodeproj/project.xcworkspace/ +diff-format.patch diff --git a/Classes/DialerView.m b/Classes/DialerView.m index 61d30a051..7f965fe07 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -271,22 +271,30 @@ static UICompositeViewDescription *compositeDescription = nil; [Log enableLogs:newDebugLevel]; }]; - [alertView addButtonWithTitle:NSLocalizedString(@"Remove account(s) and self destruct", nil) - block:^{ - linphone_core_clear_proxy_config([LinphoneManager getLc]); - linphone_core_clear_all_auth_info([LinphoneManager getLc]); - [LinphoneManager.instance destroyLinphoneCore]; - if ([NSFileManager.defaultManager - isDeletableFileAtPath:[LinphoneManager documentFile:@"linphonerc"]] == YES) { - [NSFileManager.defaultManager - removeItemAtPath:[LinphoneManager documentFile:@"linphonerc"] - error:nil]; - } + [alertView + addButtonWithTitle:NSLocalizedString(@"Remove account(s) and self destruct", nil) + block:^{ + linphone_core_clear_proxy_config([LinphoneManager getLc]); + linphone_core_clear_all_auth_info([LinphoneManager getLc]); + @try { + [LinphoneManager.instance destroyLinphoneCore]; + } @catch (NSException *e) { + LOGW(@"Exception while destroying linphone core: %@", e); + } @finally { + if ([NSFileManager.defaultManager + isDeletableFileAtPath:[LinphoneManager documentFile:@"linphonerc"]] == YES) { + [NSFileManager.defaultManager + removeItemAtPath:[LinphoneManager documentFile:@"linphonerc"] + error:nil]; + } #ifdef DEBUG - [LinphoneManager instanceRelease]; + [LinphoneManager instanceRelease]; #endif - [UIApplication sharedApplication].keyWindow.rootViewController = nil; - }]; + } + [UIApplication sharedApplication].keyWindow.rootViewController = nil; + // make the application crash to be sure that user restart it properly + LOGF(@"Self-destructing in 3..2..1..0!"); + }]; [alertView show]; return true; diff --git a/Resources/linphonerc-factory b/Resources/linphonerc-factory index c7e7fe897..cd8d1abd2 100644 --- a/Resources/linphonerc-factory +++ b/Resources/linphonerc-factory @@ -17,6 +17,7 @@ display_filter_auto_rotate=0 #contact_filter_on_default_domain=1 #use_phone_number=0 send_logs_include_linphonerc_and_chathistory=0 +#debug_popup_magic=**00** [assistant] username_length=-1