diff --git a/stepmania/src/Crash.cpp b/stepmania/src/Crash.cpp index 1c66275535..a054947a7a 100644 --- a/stepmania/src/Crash.cpp +++ b/stepmania/src/Crash.cpp @@ -34,6 +34,9 @@ // #include "RageUtil.h" // for GotoURL HINSTANCE GotoURL(const char *url); +/* in StepMania.cpp */ +void CleanupForRestart(); + /////////////////////////////////////////////////////////////////////////// #define CODE_WINDOW (256) @@ -1445,9 +1448,16 @@ BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { return TRUE; case IDC_BUTTON_RESTART: { + /* Clear the startup mutex, since we're starting a new + * instance before ending ourself. */ + CleanupForRestart(); + char cwd[MAX_PATH]; SpliceProgramPath(cwd, MAX_PATH, ""); + TCHAR szFullAppPath[MAX_PATH]; + GetModuleFileName(NULL, szFullAppPath, MAX_PATH); + // Launch StepMania PROCESS_INFORMATION pi; STARTUPINFO si; @@ -1455,7 +1465,7 @@ BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { CreateProcess( NULL, // pointer to name of executable module - "stepmania.exe", // pointer to command line string + szFullAppPath, // pointer to command line string NULL, // process security attributes NULL, // thread security attributes false, // handle inheritance flag diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 05c03cf4c2..ddda712b2c 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -378,6 +378,11 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR CmdLine, int nCmdShow return 0L; } +void CleanupForRestart() +{ + CloseHandle( g_hMutex ); + g_hMutex = NULL; +} void CreateLoadingWindow() { @@ -502,6 +507,13 @@ BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) break; case IDC_BUTTON_RESTART: { + /* Clear the startup mutex, since we're starting a new + * instance before ending ourself. */ + CleanupForRestart(); + + TCHAR szFullAppPath[MAX_PATH]; + GetModuleFileName(NULL, szFullAppPath, MAX_PATH); + // Launch StepMania PROCESS_INFORMATION pi; STARTUPINFO si; @@ -509,7 +521,7 @@ BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) CreateProcess( NULL, // pointer to name of executable module - "stepmania.exe", // pointer to command line string + szFullAppPath, // pointer to command line string NULL, // process security attributes NULL, // thread security attributes false, // handle inheritance flag