Clean up restarting: close the mutex to make sure it actually restarts,

and don't make assumptions about the executable filename.
This commit is contained in:
Glenn Maynard
2002-10-20 03:53:45 +00:00
parent d7e458cb2f
commit 90f826b278
2 changed files with 24 additions and 2 deletions
+11 -1
View File
@@ -34,6 +34,9 @@
// #include "RageUtil.h" // for GotoURL // #include "RageUtil.h" // for GotoURL
HINSTANCE GotoURL(const char *url); HINSTANCE GotoURL(const char *url);
/* in StepMania.cpp */
void CleanupForRestart();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#define CODE_WINDOW (256) #define CODE_WINDOW (256)
@@ -1445,9 +1448,16 @@ BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
return TRUE; return TRUE;
case IDC_BUTTON_RESTART: case IDC_BUTTON_RESTART:
{ {
/* Clear the startup mutex, since we're starting a new
* instance before ending ourself. */
CleanupForRestart();
char cwd[MAX_PATH]; char cwd[MAX_PATH];
SpliceProgramPath(cwd, MAX_PATH, ""); SpliceProgramPath(cwd, MAX_PATH, "");
TCHAR szFullAppPath[MAX_PATH];
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
// Launch StepMania // Launch StepMania
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFO si; STARTUPINFO si;
@@ -1455,7 +1465,7 @@ BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
CreateProcess( CreateProcess(
NULL, // pointer to name of executable module 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, // process security attributes
NULL, // thread security attributes NULL, // thread security attributes
false, // handle inheritance flag false, // handle inheritance flag
+13 -1
View File
@@ -378,6 +378,11 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR CmdLine, int nCmdShow
return 0L; return 0L;
} }
void CleanupForRestart()
{
CloseHandle( g_hMutex );
g_hMutex = NULL;
}
void CreateLoadingWindow() void CreateLoadingWindow()
{ {
@@ -502,6 +507,13 @@ BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
break; break;
case IDC_BUTTON_RESTART: 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 // Launch StepMania
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
STARTUPINFO si; STARTUPINFO si;
@@ -509,7 +521,7 @@ BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
CreateProcess( CreateProcess(
NULL, // pointer to name of executable module 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, // process security attributes
NULL, // thread security attributes NULL, // thread security attributes
false, // handle inheritance flag false, // handle inheritance flag