Dialer: add try/catch around self destruct code

This commit is contained in:
Gautier Pelloux-Prayer 2016-02-10 15:05:19 +01:00
parent 9d07fe090d
commit bd0b56276a
3 changed files with 24 additions and 14 deletions

1
.gitignore vendored
View file

@ -16,3 +16,4 @@ submodules/tunnel
submodules/binaries/dummy-*.a
linphone-iphone.ipa
TutorialHellowWorld/hello-world.xcodeproj/project.xcworkspace/
diff-format.patch

View file

@ -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;

View file

@ -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