From 9217b4ebcdef41aaa2d25f11ea52b26305a1260a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Mon, 6 Jun 2016 16:05:11 +0200 Subject: [PATCH] fix crash when showing insert disk menu after shutting down the emulated machine --- Mini vMac/EmulatorProtocol.h | 1 - Mini vMac/MYOSGLUE.m | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Mini vMac/EmulatorProtocol.h b/Mini vMac/EmulatorProtocol.h index 7429265..cd572a6 100644 --- a/Mini vMac/EmulatorProtocol.h +++ b/Mini vMac/EmulatorProtocol.h @@ -22,7 +22,6 @@ @property (nonatomic, readonly) NSString *insertDiskNotification, *ejectDiskNotification; @property (nonatomic, readonly) NSInteger initialSpeed; -@property (nonatomic, readonly) NSData *RAM; @property (nonatomic, readonly) BOOL anyDiskInserted; @property (nonatomic, readonly) NSString *currentApplication; diff --git a/Mini vMac/MYOSGLUE.m b/Mini vMac/MYOSGLUE.m index 8c664dc..b5984bf 100644 --- a/Mini vMac/MYOSGLUE.m +++ b/Mini vMac/MYOSGLUE.m @@ -36,6 +36,8 @@ #define kRAM_Size (kRAMa_Size + kRAMb_Size) EXPORTVAR(ui3p, RAM) +EXPORTVAR(ui3p, VidROM) +EXPORTVAR(ui3p, VidMem) @interface Emulator : NSObject @@ -1512,6 +1514,13 @@ LOCALFUNC blnr AllocMyMemory(void) { LOCALPROC UnallocMyMemory(void) { if (nullpr != ReserveAllocBigBlock) { free((char *)ReserveAllocBigBlock); + RAM = nullpr; +#if EmVidCard + VidROM = nullpr; +#endif +#if IncludeVidMem + VidMem = nullpr; +#endif } } @@ -1772,12 +1781,11 @@ static dispatch_once_t onceToken; WantMacReset = trueblnr; } -- (NSData *)RAM { - return [NSData dataWithBytesNoCopy:RAM length:kRAM_Size freeWhenDone:NO]; -} - - (NSString *)currentApplication { - NSData *curApName = [self.RAM subdataWithRange:NSMakeRange(0x910, 32)]; + if (RAM == nullpr) { + return nil; + } + NSData *curApName = [NSData dataWithBytes:RAM + 0x910 length:32]; uint8_t curApNameLength = *(uint8_t*)curApName.bytes; if (curApNameLength == 0 || curApNameLength > 31) { return nil;