diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-10-29 10:03:59 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-11-06 07:44:54 -0500 |
| commit | 8c72077febaea485200adcf1e9f615902e930def (patch) | |
| tree | 13fe30db88d40d1554343b40cb33e9dcf846db7d /src/spawn.cpp | |
| parent | 18b438cf27a552e69e984bfee63187b6471682ab (diff) | |
replaced uilock by a progress callback in spawn
waiting for process now gets the whole process tree to find an interesting process
Diffstat (limited to 'src/spawn.cpp')
| -rw-r--r-- | src/spawn.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/spawn.cpp b/src/spawn.cpp index 1003024f..0ea60641 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -1095,32 +1095,25 @@ FileExecutionContext getFileExecutionContext( }
WaitResults waitForProcess(
- HANDLE handle, DWORD* exitCode, ILockedWaitingForProcess* uilock)
+ HANDLE handle, DWORD* exitCode, std::function<bool ()> progress)
{
if (handle == INVALID_HANDLE_VALUE) {
return WaitResults::Error;
}
- const DWORD pid = ::GetProcessId(handle);
- const QString processName = QString("%1 (%2)")
- .arg(env::getProcessName(handle))
- .arg(pid);
-
- if (uilock)
- uilock->setProcessName(processName);
-
- log::debug(
- "waiting for process completion '{}' ({})",
- processName, pid);
+ log::debug("waiting for completion on pid {}", ::GetProcessId(handle));
std::vector<HANDLE> handles;
handles.push_back(handle);
std::vector<DWORD> exitCodes;
- const auto r = waitForProcesses(handles, exitCodes, uilock);
- if (exitCode && !exitCodes.empty()) {
- *exitCode = exitCodes[0];
+ const auto r = waitForProcesses(handles, exitCodes, progress);
+
+ if (r == WaitResults::Completed) {
+ if (exitCode && !exitCodes.empty()) {
+ *exitCode = exitCodes[0];
+ }
}
return r;
@@ -1128,7 +1121,7 @@ WaitResults waitForProcess( WaitResults waitForProcesses(
const std::vector<HANDLE>& handles, std::vector<DWORD>& exitCodes,
- ILockedWaitingForProcess* uilock)
+ std::function<bool ()> progress)
{
if (handles.empty()) {
return WaitResults::Completed;
@@ -1175,8 +1168,8 @@ WaitResults waitForProcesses( QCoreApplication::sendPostedEvents();
QCoreApplication::processEvents();
- if (uilock && uilock->unlockForced()) {
- return WaitResults::Unlocked;
+ if (progress && progress()) {
+ return WaitResults::Cancelled;
}
}
}
|
