From aacc0a720fc193c34553ac2fbf03ce02cea9db64 Mon Sep 17 00:00:00 2001 From: Bush2021 <79072750+Bush2021@users.noreply.github.com> Date: Fri, 6 Dec 2024 12:31:19 -0500 Subject: [PATCH] fix: skip redundant operations when `GetLaunchOn[Startup/Exit]` are empty `WaitForSingleObject` causes the IDM floating bar to not display (#130). This commit attempts to avoid calling `WaitForSingleObject` and advises end users to avoid using this function until a better method is implemented. --- src/chrome++.ini | Bin 12004 -> 12478 bytes src/portable.h | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/chrome++.ini b/src/chrome++.ini index 203eb89b63b1bea573bfe894358c60bde68a4e84..bec0d65a592d56ed2b58e1ff32a20b6308fb01b2 100644 GIT binary patch delta 461 zcmYk2KTE?<6vZ!&(%8i*AY|+yBDhr$6c>@cLKl%xF>MkPnm^JcmI_h@2cbiUf`Ws7 z07VK;E`AHa(ZPbV6a=Znb6;ANz* program_handles) { } void Portable(LPWSTR param) { - std::vector program_handles = {nullptr}; bool first_run = IsFirstRun(); - if (first_run) { - LaunchCommands(GetLaunchOnStartup(), SW_SHOW, &program_handles); + auto launch_on_startup = GetLaunchOnStartup(); + auto launch_on_exit = GetLaunchOnExit(); + std::vector program_handles = {nullptr}; + + if (first_run && !launch_on_startup.empty()) { + LaunchCommands(launch_on_startup, SW_SHOW, &program_handles); } wchar_t path[MAX_PATH]; @@ -129,11 +133,15 @@ void Portable(LPWSTR param) { sei.lpParameters = args.c_str(); if (ShellExecuteEx(&sei)) { - if (first_run) { + if (first_run && !launch_on_exit.empty()) { + // `WaitForSingleObject` causes IDM floating bar not to be displayed. + // Hence, end users should be reminded to avoid using this feature until a + // better method is implemented. See: + // https://github.com/Bush2021/chrome_plus/issues/130 WaitForSingleObject(sei.hProcess, INFINITE); CloseHandle(hMutex); KillLaunchOnExit(&program_handles); - LaunchCommands(GetLaunchOnExit(), SW_HIDE, nullptr); + LaunchCommands(launch_on_exit, SW_HIDE, nullptr); } ExitProcess(0); }