.mm: try to simplify load of .mm files

This commit is contained in:
C.W. Betts
2021-10-02 17:12:45 +02:00
committed by Celtic Minstrel
parent cd39a11f93
commit 1ce5edaa91
3 changed files with 10 additions and 25 deletions

View File

@@ -25,7 +25,8 @@ extern fs::path file_in_mem;
void set_up_apple_events(int argc, char* argv[]); // Suppress "no prototype" warning
void set_up_apple_events(int, char*[]) {
AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init];
static AppleEventHandler* aeHandler;
aeHandler = [[AppleEventHandler alloc] init];
[[NSApplication sharedApplication] setDelegate: aeHandler];
}
@@ -33,13 +34,7 @@ void set_up_apple_events(int, char*[]) {
-(BOOL)application:(NSApplication*) app openFile:(NSString*) file {
(void) app; // Suppress "unused parameter" warning
unsigned long len = [file length], sz = len + 1;
auto msg = std::shared_ptr<unichar>(new unichar[sz], std::default_delete<unichar[]>());
std::fill(msg.get(), msg.get() + sz, 0);
[file getCharacters: msg.get() range: (NSRange){0, len}];
std::string fileName;
std::copy(msg.get(), msg.get() + len, std::inserter(fileName, fileName.begin()));
std::string fileName=file.fileSystemRepresentation;
if(load_party(fileName, univ)) {
file_in_mem = fileName;
party_in_scen = !univ.party.scen_name.empty();