From e06da76068910fc5e7b42514d421e68f479a7e08 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Tue, 26 May 2020 19:36:16 +0200 Subject: [PATCH] fix crash: IASKAppSettingsView is load before app entering foreground --- Classes/SettingsView.m | 23 +++++++++++-------- .../IASKAppSettingsViewController.m | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index 7a9bfdad0..d50267a99 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -196,18 +196,23 @@ - (IASKSettingsReader *)settingsReader { IASKSettingsReader *r = [super settingsReader]; NSMutableArray *dataSource = [NSMutableArray arrayWithArray:[r dataSource]]; - for (int i = 0; i < [dataSource count]; ++i) { - NSMutableArray *specifiers = [NSMutableArray arrayWithArray:[dataSource objectAtIndex:i]]; - for (int j = 0; j < [specifiers count]; ++j) { - id sp = [specifiers objectAtIndex:j]; - if ([sp isKindOfClass:[IASKSpecifier class]]) { - sp = [SettingsView filterSpecifier:sp]; + if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateBackground) { + for (int i = 0; i < [dataSource count]; ++i) { + NSMutableArray *specifiers = [NSMutableArray arrayWithArray:[dataSource objectAtIndex:i]]; + for (int j = 0; j < [specifiers count]; ++j) { + id sp = [specifiers objectAtIndex:j]; + if ([sp isKindOfClass:[IASKSpecifier class]]) { + sp = [SettingsView filterSpecifier:sp]; + } + [specifiers replaceObjectAtIndex:j withObject:sp]; } - [specifiers replaceObjectAtIndex:j withObject:sp]; - } - [dataSource replaceObjectAtIndex:i withObject:specifiers]; + [dataSource replaceObjectAtIndex:i withObject:specifiers]; + } + } else { + NSLog(@"Application is in background, linphonecore is off, skiping filter specifier."); } + [r setDataSource:dataSource]; return r; } diff --git a/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m b/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m index 739ef33af..6156fb1d8 100755 --- a/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m +++ b/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m @@ -242,8 +242,8 @@ CGRect IASKCGRectSwap(CGRect rect); [super viewDidDisappear:animated]; } -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return YES; +- (BOOL)shouldAutorotate { + return YES; } - (void)didReceiveMemoryWarning {