[RAPPS] Use different mutex and title for AppWiz mode (#7350)

The two different modes needs separate mutex and window titles, otherwise you can end up stuck in AppWiz mode.
This commit is contained in:
Whindmar Saksit 2024-09-26 18:06:13 +02:00 committed by GitHub
parent 4f4be5c498
commit 2f83e6a65d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -749,8 +749,7 @@ CMainWindow::GetWndClassInfo()
HWND
CMainWindow::Create()
{
CStringW szWindowName;
szWindowName.LoadStringW(IDS_APPTITLE);
const CStringW szWindowName(MAKEINTRESOURCEW(m_bAppwizMode ? IDS_APPWIZ_TITLE : IDS_APPTITLE));
RECT r = {
(SettingsInfo.bSaveWndPos ? SettingsInfo.Left : CW_USEDEFAULT),

View file

@ -349,16 +349,17 @@ ParseCmdAndExecute(LPWSTR lpCmdLine, BOOL bIsFirstLaunch, int nCmdShow)
if (argc == 1 || bAppwizMode) // RAPPS is launched without options or APPWIZ mode is requested
{
// Check whether the RAPPS MainWindow is already launched in another process
HANDLE hMutex;
CStringW szWindowText(MAKEINTRESOURCEW(bAppwizMode ? IDS_APPWIZ_TITLE : IDS_APPTITLE));
LPCWSTR pszMutex = bAppwizMode ? L"RAPPWIZ" : szWindowClass;
hMutex = CreateMutexW(NULL, FALSE, szWindowClass);
HANDLE hMutex = CreateMutexW(NULL, FALSE, pszMutex);
if ((!hMutex) || (GetLastError() == ERROR_ALREADY_EXISTS))
{
/* If already started, find its window */
HWND hWindow;
for (int wait = 2500, inter = 250; wait > 0; wait -= inter)
{
if ((hWindow = FindWindowW(szWindowClass, NULL)) != NULL)
if ((hWindow = FindWindowW(szWindowClass, szWindowText)) != NULL)
break;
Sleep(inter);
}
@ -376,6 +377,7 @@ ParseCmdAndExecute(LPWSTR lpCmdLine, BOOL bIsFirstLaunch, int nCmdShow)
return FALSE;
}
}
szWindowText.Empty();
CMainWindow wnd(&db, bAppwizMode);
MainWindowLoop(&wnd, nCmdShow);