diff --git a/CMakeLists.txt b/CMakeLists.txt index e5946a516b..a73684bf8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -692,6 +692,11 @@ elseif(IOS) set_source_files_properties(ios/AppDelegate.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) set_source_files_properties(ios/ViewController.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) + set_source_files_properties(ios/iOSCoreAudio.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) + set_source_files_properties(ios/PPSSPPUIApplication.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) + set_source_files_properties(ios/iCade/iCadeReaderView.m PROPERTIES COMPILE_FLAGS -fobjc-arc) + set_source_files_properties(ios/main.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) + set(TargetBin PPSSPP) elseif(USING_QT_UI) diff --git a/ios/PPSSPPUIApplication.mm b/ios/PPSSPPUIApplication.mm index c535081b99..d07e7a26e0 100644 --- a/ios/PPSSPPUIApplication.mm +++ b/ios/PPSSPPUIApplication.mm @@ -60,12 +60,6 @@ @implementation PPSSPPUIApplication -- (instancetype)init { - auto instance = [super init]; - instance.delegate = [[AppDelegate alloc] init]; - return instance; -} - - (void)decodeKeyEvent:(NSInteger *)eventMem { NSInteger eventType = eventMem[GSEVENT_TYPE]; NSInteger eventScanCode = eventMem[GSEVENTKEY_KEYCODE]; diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 528287094c..c49a550710 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -66,7 +66,7 @@ extern ScreenManager *screenManager; extern bool iosCanUseJit; extern bool targetIsJailbroken; -ViewController* sharedViewController; +__unsafe_unretained static ViewController* sharedViewController; static GraphicsContext *graphicsContext; @interface ViewController () @@ -74,10 +74,10 @@ static GraphicsContext *graphicsContext; std::map iCadeToKeyMap; } -@property (nonatomic) EAGLContext* context; -@property (nonatomic) NSString* documentsPath; -@property (nonatomic) NSString* bundlePath; -@property (nonatomic) NSMutableArray* touches; +@property (nonatomic, strong) EAGLContext* context; +@property (nonatomic, strong) NSString* documentsPath; +@property (nonatomic, strong) NSString* bundlePath; +@property (nonatomic, strong) NSMutableArray* touches; @property (nonatomic) AudioEngine* audioEngine; //@property (nonatomic) iCadeReaderView* iCadeView; #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 @@ -214,16 +214,6 @@ static GraphicsContext *graphicsContext; #endif } -- (void)viewDidUnload -{ - [super viewDidUnload]; - - if ([EAGLContext currentContext] == self.context) { - [EAGLContext setCurrentContext:nil]; - } - self.context = nil; -} - - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; @@ -231,7 +221,12 @@ static GraphicsContext *graphicsContext; - (void)dealloc { - [self viewDidUnload]; + sharedViewController = nil; + + if ([EAGLContext currentContext] == self.context) { + [EAGLContext setCurrentContext:nil]; + } + self.context = nil; #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 if ([GCController class]) { diff --git a/ios/iCade/iCadeReaderView.h b/ios/iCade/iCadeReaderView.h index 2f39a3dd52..8a6bb586f9 100755 --- a/ios/iCade/iCadeReaderView.h +++ b/ios/iCade/iCadeReaderView.h @@ -50,7 +50,7 @@ @interface iCadeReaderView : UIView { UIView *inputView; iCadeState _iCadeState; - id _delegate; + id __weak _delegate; struct { bool stateChanged:1; @@ -60,7 +60,7 @@ } @property (nonatomic, assign) iCadeState iCadeState; -@property (nonatomic, assign) id delegate; +@property (nonatomic, weak) id delegate; @property (nonatomic, assign) BOOL active; @end diff --git a/ios/iCade/iCadeReaderView.m b/ios/iCade/iCadeReaderView.m index 48a0a59df3..cd0e94fa59 100755 --- a/ios/iCade/iCadeReaderView.m +++ b/ios/iCade/iCadeReaderView.m @@ -49,7 +49,6 @@ static const char *OFF_STATES = "eczqtrfnmpgv"; - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; - [super dealloc]; } - (void)didEnterBackground { diff --git a/ios/main.mm b/ios/main.mm index 3070e772d6..c6eb2d3c7f 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -113,7 +113,6 @@ int main(int argc, char *argv[]) // Simulates a debugger. Makes it possible to use JIT (though only W^X) syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0); @autoreleasepool { - return UIApplicationMain(argc, argv, NSStringFromClass([PPSSPPUIApplication class]), nil); - //return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + return UIApplicationMain(argc, argv, NSStringFromClass([PPSSPPUIApplication class]), NSStringFromClass([AppDelegate class])); } }