mirror of
https://github.com/LIJI32/SameBoy.git
synced 2026-10-11 22:19:50 +00:00
Fix several iOS crashes
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
+10
-3
@@ -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] ||
|
||||
|
||||
Reference in New Issue
Block a user