mirror of https://github.com/LIJI32/SameBoy.git
Fix several iOS crashes
This commit is contained in:
parent
8f21c8ed66
commit
71d4e60c57
|
@ -223,6 +223,7 @@ void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *_cheat, const char *des
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(cheat);
|
assert(cheat);
|
||||||
|
if (!cheat) return;
|
||||||
|
|
||||||
if (cheat->address != address) {
|
if (cheat->address != address) {
|
||||||
/* Remove from old bucket */
|
/* Remove from old bucket */
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
{
|
{
|
||||||
NSIndexPath *_renamingPath;
|
NSIndexPath *_renamingPath;
|
||||||
NSArray *_roms;
|
NSArray *_roms;
|
||||||
|
__weak UIAlertController *_alertToRemove;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
|
@ -204,6 +205,7 @@
|
||||||
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
|
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
|
||||||
style:UIAlertActionStyleCancel
|
style:UIAlertActionStyleCancel
|
||||||
handler:nil]];
|
handler:nil]];
|
||||||
|
_alertToRemove = alert; // indexPath becoomes invalid if we reload, dismiss the alert if it happens
|
||||||
[self presentViewController:alert animated:true completion:nil];
|
[self presentViewController:alert animated:true completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,6 +323,9 @@ contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
// Do not auto-reload if busy
|
// Do not auto-reload if busy
|
||||||
if (self.view.window.userInteractionEnabled) {
|
if (self.view.window.userInteractionEnabled) {
|
||||||
[self.tableView reloadData];
|
[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)
|
static NSString *LocalizedNameForElement(GCControllerElement *element, GBControllerUsage usage)
|
||||||
{
|
{
|
||||||
if (@available(iOS 14.0, *)) {
|
if (@available(iOS 14.0, *)) {
|
||||||
return element.localizedName;
|
return element.localizedName ?: @"Unknown Button";
|
||||||
}
|
}
|
||||||
switch (usage) {
|
switch (usage) {
|
||||||
case GBUsageDpad: return @"D-Pad";
|
case GBUsageDpad: return @"D-Pad";
|
||||||
|
|
|
@ -731,9 +731,16 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDate *date = nil;
|
NSDate *date = nil;
|
||||||
[[NSURL fileURLWithPath:[GBROMManager sharedManager].autosaveStateFile] getResourceValue:&date
|
@try {
|
||||||
forKey:NSURLContentModificationDateKey
|
[[NSURL fileURLWithPath:[GBROMManager sharedManager].autosaveStateFile] getResourceValue:&date
|
||||||
error:nil];
|
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
|
// Reset the rewind buffer only if we switched ROMs or had the save state change externally
|
||||||
if (![_lastSavedROM isEqual:[GBROMManager sharedManager].currentROM] ||
|
if (![_lastSavedROM isEqual:[GBROMManager sharedManager].currentROM] ||
|
||||||
|
|
Loading…
Reference in New Issue