diff --git a/meson.build b/meson.build index f29ba0c0f..4a387ac12 100644 --- a/meson.build +++ b/meson.build @@ -135,6 +135,9 @@ if copt_msvc args_msvc_opt = [ '/Oy-', '/fp:fast' ] project_c_args += args_msvc_opt project_cpp_args += args_msvc_opt + project_link_args += [ + '/NODEFAULTLIB:LIBCMT', + ] endif else if copt_platform == 'mac' diff --git a/src/Platform.cpp b/src/Platform.cpp index d5cdf725a..72bc1325e 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -19,6 +19,7 @@ #endif #include "Misc.h" +#include "client/Client.h" namespace Platform { @@ -80,11 +81,26 @@ void DoRestart() if (exename.length()) { #ifdef WIN - ShellExecute(NULL, "open", exename.c_str(), NULL, NULL, SW_SHOWNORMAL); + int ret = (int)ShellExecute(NULL, NULL, exename.c_str(), NULL, NULL, SW_SHOWNORMAL); + if (ret <= 32) + { + fprintf(stderr, "cannot restart: ShellExecute(...) failed: code %i\n", ret); + } + else + { + Client::Ref().Shutdown(); // very ugly hack; will fix soon(tm) + exit(0); + } #elif defined(LIN) || defined(MACOSX) execl(exename.c_str(), "powder", NULL); + int ret = errno; + fprintf(stderr, "cannot restart: execl(...) failed: code %i\n", ret); #endif } + else + { + fprintf(stderr, "cannot restart: no executable name???\n"); + } exit(-1); }