SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 71d4e60c57388cc86f1e60806566047fbf7b4be5 parent 8f21c8ed669e0309114684ac38712d6d97e88374 Author: Lior Halphon <LIJI32@gmail.com> Date: Thu, 3 Apr 2025 23:37:11 +0300 Fix several iOS crashes Diffstat:
| M | Core/cheats.c | 1 | + |
| M | iOS/GBROMViewController.m | 5 | +++++ |
| M | iOS/GBSettingsViewController.m | 2 | +- |
| M | iOS/GBViewController.m | 13 | ++++++++++--- |
4 files changed, 17 insertions(+), 4 deletions(-)
diff --git 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 @@ -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 @@ -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 @@ -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] ||
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.