git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit ebfc877c1cc4933cc40b035bc9febef4b53378fa
parent 8f9e1e9ea5c33e1a22013e4b95395303cff94ad0
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Thu, 21 Nov 2024 17:52:31 +0200

Fixed a bug that resulted in crashes if the ROM list changed while the library was open.

Diffstat:
MiOS/GBROMViewController.m16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/iOS/GBROMViewController.m b/iOS/GBROMViewController.m @@ -8,6 +8,7 @@ @implementation GBROMViewController { NSIndexPath *_renamingPath; + NSArray *_roms; } - (instancetype)init @@ -20,6 +21,11 @@ name:UIApplicationDidBecomeActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self.tableView + selector:@selector(reloadData) + name:UIApplicationDidBecomeActiveNotification + object:nil]; + return self; } @@ -31,7 +37,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 1) return 2; - return [GBROMManager sharedManager].allROMs.count; + return (_roms = [GBROMManager sharedManager].allROMs).count; } - (UITableViewCell *)cellForROM:(NSString *)rom @@ -72,7 +78,7 @@ } return cell; } - return [self cellForROM:[GBROMManager sharedManager].allROMs[[indexPath indexAtPosition:1]]]; + return [self cellForROM:_roms[[indexPath indexAtPosition:1]]]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath @@ -96,7 +102,7 @@ - (void)romSelectedAtIndex:(unsigned)index { - NSString *rom = [GBROMManager sharedManager].allROMs[index]; + NSString *rom = _roms[index]; [GBROMManager sharedManager].currentROM = rom; [self.presentingViewController dismissViewControllerAnimated:true completion:nil]; } @@ -178,7 +184,7 @@ - (void)deleteROMAtIndex:(unsigned)index { - NSString *rom = [GBROMManager sharedManager].allROMs[index]; + NSString *rom = _roms[index]; [[GBROMManager sharedManager] deleteROM:rom]; [self.tableView deleteRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic]; @@ -265,7 +271,7 @@ - (void)duplicateROMAtIndex:(unsigned)index { - [[GBROMManager sharedManager] duplicateROM:[GBROMManager sharedManager].allROMs[index]]; + [[GBROMManager sharedManager] duplicateROM:_roms[index]]; [self.tableView reloadData]; }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.