Skip to content

Commit

Permalink
Fixed freezing/crashing with previous commit.
Browse files Browse the repository at this point in the history
Fix.
  • Loading branch information
hjstn committed Sep 23, 2016
1 parent 8b889f4 commit 505ab19
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions iNDS/iNDSEmulatorViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ - (void)viewDidLoad
[notificationCenter addObserver:self selector:@selector(screenChanged:) name:UIScreenDidDisconnectNotification object:nil];
[notificationCenter addObserver:self selector:@selector(controllerActivated:) name:GCControllerDidConnectNotification object:nil];
[notificationCenter addObserver:self selector:@selector(controllerDeactivated:) name:GCControllerDidDisconnectNotification object:nil];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"mirrorDisplay" options:NSKeyValueObservingOptionNew context:NULL];

if ([[GCController controllers] count] > 0) {
[self controllerActivated:nil];
Expand Down Expand Up @@ -338,6 +339,13 @@ - (void)loadProfile:(iNDSEmulationProfile *)profile

}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if([keyPath isEqual: @"mirrorDisplay"] && emuLoopLock) {
[self performSelector:@selector(screenChanged:)];
}
}

- (void)defaultsChanged:(NSNotification*)notification
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
Expand All @@ -354,9 +362,6 @@ - (void)defaultsChanged:(NSNotification*)notification
int filterTranslate[] = {NONE, EPX, SUPEREAGLE, _2XSAI, SUPER2XSAI, BRZ2x, LQ2X, BRZ3x, HQ2X, HQ4X, BRZ4x, BRZ5x};
NSInteger filter = [[NSUserDefaults standardUserDefaults] integerForKey:@"videoFilter"];
EMU_setFilter(filterTranslate[filter]);

// Mirror Display
[self performSelector:@selector(screenChanged:) withObject:notification];
}
self.directionalControl.style = [defaults integerForKey:@"controlPadStyle"];
self.fpsLabel.hidden = ![defaults integerForKey:@"showFPS"];
Expand Down Expand Up @@ -418,6 +423,7 @@ - (void)dealloc
{
EMU_closeRom();
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:@"mirrorDisplay"];
}

- (void)screenChanged:(NSNotification*)notification
Expand Down

0 comments on commit 505ab19

Please sign in to comment.