From 2aa70de49e89245467299d94d76825bad31c63a2 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Tue, 29 Oct 2019 13:46:33 -0400 Subject: return failure if the user has unlocked in waitForApplication() --- src/processrunner.cpp | 34 ++++++++++++++++++---------------- src/processrunner.h | 3 --- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/processrunner.cpp b/src/processrunner.cpp index 014f98ee..5d4a9fde 100644 --- a/src/processrunner.cpp +++ b/src/processrunner.cpp @@ -243,6 +243,14 @@ WaitResults waitForProcesses( } } +WaitResults waitForProcess( + HANDLE initialProcess, LPDWORD exitCode, ILockedWaitingForProcess* uilock) +{ + std::vector processes = {initialProcess}; + return waitForProcesses(processes, exitCode, uilock); +} + + SpawnedProcess::SpawnedProcess(HANDLE handle, spawn::SpawnParameters sp) : m_handle(handle), m_parameters(std::move(sp)) @@ -617,18 +625,20 @@ bool ProcessRunner::waitForProcessCompletionWithLock( return true; } - bool r = false; + auto r = WaitResults::Error; withLock([&](auto* uilock) { - r = waitForProcessCompletion(handle, exitCode, uilock); + r = waitForProcess(handle, exitCode, uilock); }); - return r; + // completed/unlocked is fine + return (r != WaitResults::Error); } bool ProcessRunner::waitForApplication(HANDLE handle, LPDWORD exitCode) { - // don't check for lockGUI() setting; this _always_ locks the ui + // don't check for lockGUI() setting; this _always_ locks the ui and waits + // for completion // // this is typically called only from OrganizerProxy, which allows plugins // to wait on applications until they're finished @@ -637,22 +647,14 @@ bool ProcessRunner::waitForApplication(HANDLE handle, LPDWORD exitCode) // and then check the exit code; this has to work regardless of the locking // setting - bool r = false; + auto r = WaitResults::Error; withLock([&](auto* uilock) { - r = waitForProcessCompletion(handle, exitCode, uilock); + r = waitForProcess(handle, exitCode, uilock); }); - return r; -} - -bool ProcessRunner::waitForProcessCompletion( - HANDLE handle, LPDWORD exitCode, ILockedWaitingForProcess* uilock) -{ - std::vector processes = {handle}; - const auto r = waitForProcesses(processes, exitCode, uilock); - - return (r != WaitResults::Error); + // treat unlocked as an error since this should always wait for completion + return (r == WaitResults::Completed); } bool ProcessRunner::waitForAllUSVFSProcessesWithLock() diff --git a/src/processrunner.h b/src/processrunner.h index d9423893..28f4da75 100644 --- a/src/processrunner.h +++ b/src/processrunner.h @@ -80,9 +80,6 @@ private: bool waitForProcessCompletionWithLock(HANDLE handle, LPDWORD exitCode); - bool waitForProcessCompletion( - HANDLE handle, LPDWORD exitCode, ILockedWaitingForProcess* uilock); - bool waitForAllUSVFSProcesses(ILockedWaitingForProcess* uilock); }; -- cgit v1.3.1