Fix several iOS crashes

This commit is contained in:
Lior Halphon 2025-04-03 23:37:11 +03:00
parent 8f21c8ed66
commit 71d4e60c57
4 changed files with 17 additions and 4 deletions

View File

@ -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 */

View File

@ -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];
}
}
}

View File

@ -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";

View File

@ -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] ||