From f053fda3c863d8c2769ca8537613c36b80e609aa Mon Sep 17 00:00:00 2001 From: kanjitalk755 Date: Sat, 16 Jun 2018 13:33:13 +0900 Subject: [PATCH] fix for sheepvm --- BasiliskII/src/MacOSX/utils_macosx.mm | 2 ++ SheepShaver/src/Unix/main_unix.cpp | 38 ++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/BasiliskII/src/MacOSX/utils_macosx.mm b/BasiliskII/src/MacOSX/utils_macosx.mm index 59cd0f1d..a0a0d01c 100644 --- a/BasiliskII/src/MacOSX/utils_macosx.mm +++ b/BasiliskII/src/MacOSX/utils_macosx.mm @@ -78,6 +78,8 @@ void set_menu_bar_visible_osx(bool visible) void set_current_directory() { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; chdir([[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] UTF8String]); + [pool release]; } diff --git a/SheepShaver/src/Unix/main_unix.cpp b/SheepShaver/src/Unix/main_unix.cpp index a0971386..e30ca984 100755 --- a/SheepShaver/src/Unix/main_unix.cpp +++ b/SheepShaver/src/Unix/main_unix.cpp @@ -124,6 +124,7 @@ #ifdef USE_SDL #include +#include #endif #ifndef USE_SDL_VIDEO @@ -673,6 +674,9 @@ static bool install_signal_handlers(void) } #ifdef USE_SDL + +static std::string sdl_vmdir; + static bool init_sdl() { int sdl_flags = 0; @@ -700,6 +704,18 @@ static bool init_sdl() } atexit(SDL_Quit); +#if SDL_VERSION_ATLEAST(2,0,0) + for (int i = 0; i < 100; i++) { + SDL_Event event; + SDL_PollEvent(&event); + if (event.type == SDL_DROPFILE) { + sdl_vmdir = event.drop.file; + break; + } + SDL_Delay(1); + } +#endif + #if __MACOSX__ // On Mac OS X hosts, SDL2 will create its own menu bar. This is mostly OK, // except that it will also install keyboard shortcuts, such as Command + Q, @@ -743,6 +759,22 @@ int main(int argc, char **argv) #endif #endif +#ifdef USE_SDL + // Initialize SDL system + if (!init_sdl()) + goto quit; +#if SDL_VERSION_ATLEAST(2,0,0) + if (valid_vmdir(sdl_vmdir.c_str())) { + vmdir = sdl_vmdir.c_str(); + printf("Using %s as vmdir.\n", vmdir); + if (chdir(vmdir)) { + printf("Failed to chdir to %s. Good bye.", vmdir); + exit(1); + } + } +#endif +#endif + // Parse command line arguments for (int i=1; i