diff --git a/Core/cheats.c b/Core/cheats.c index cf2a690..d8b25e9 100644 --- a/Core/cheats.c +++ b/Core/cheats.c @@ -223,6 +223,7 @@ void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *_cheat, const char *des } assert(cheat); + if (!cheat) return; if (cheat->address != address) { /* Remove from old bucket */ diff --git a/iOS/GBROMViewController.m b/iOS/GBROMViewController.m index e74ab29..692f845 100644 --- a/iOS/GBROMViewController.m +++ b/iOS/GBROMViewController.m @@ -9,6 +9,7 @@ { NSIndexPath *_renamingPath; NSArray *_roms; + __weak UIAlertController *_alertToRemove; } - (instancetype)init @@ -204,6 +205,7 @@ [alert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; + _alertToRemove = alert; // indexPath becoomes invalid if we reload, dismiss the alert if it happens [self presentViewController:alert animated:true completion:nil]; } @@ -321,6 +323,9 @@ contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath // Do not auto-reload if busy if (self.view.window.userInteractionEnabled) { [self.tableView reloadData]; + if (self.presentedViewController == _alertToRemove) { + [self dismissViewControllerAnimated:true completion:nil]; + } } } diff --git a/iOS/GBSettingsViewController.m b/iOS/GBSettingsViewController.m index b31113a..286691d 100644 --- a/iOS/GBSettingsViewController.m +++ b/iOS/GBSettingsViewController.m @@ -506,7 +506,7 @@ static UIImage *ImageForController(GCController *controller) static NSString *LocalizedNameForElement(GCControllerElement *element, GBControllerUsage usage) { if (@available(iOS 14.0, *)) { - return element.localizedName; + return element.localizedName ?: @"Unknown Button"; } switch (usage) { case GBUsageDpad: return @"D-Pad"; diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m index c786195..f02ea88 100644 --- a/iOS/GBViewController.m +++ b/iOS/GBViewController.m @@ -731,9 +731,16 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) } NSDate *date = nil; - [[NSURL fileURLWithPath:[GBROMManager sharedManager].autosaveStateFile] getResourceValue:&date - forKey:NSURLContentModificationDateKey - error:nil]; + @try { + [[NSURL fileURLWithPath:[GBROMManager sharedManager].autosaveStateFile] getResourceValue:&date + forKey:NSURLContentModificationDateKey + error:nil]; + } + @catch (NSException *exception) { + /* fileURLWithPath: throws an exception on some crash logs. I don't know why or how to reproduce it, + but let's at least not crash. */ + GB_rewind_reset(&_gb); + } // Reset the rewind buffer only if we switched ROMs or had the save state change externally if (![_lastSavedROM isEqual:[GBROMManager sharedManager].currentROM] ||