From a92fc98246f351ed6657788b9b12aca7cce4771a Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Sun, 5 Nov 2017 13:47:00 -0600 Subject: Remove cruft and reapply input event listening on subprocess delay --- src/organizercore.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index deb47d74..d12b77b9 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1253,13 +1253,11 @@ bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode) LPDWORD processes = new DWORD[maxCount]; std::map handles; - DWORD currentProcess = 0UL; bool tryAgain = true; DWORD moProcess = -1; DWORD res; // Wait for a an event on the handle, a key press, mouse click or timeout - //TODO: Remove MOBase::isOneOf from this query as it was always returning true. while ( res = ::MsgWaitForMultipleObjects(1, &handle, false, 500, QS_KEY | QS_MOUSE), @@ -1304,20 +1302,22 @@ bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode) } } + // Update the lock process name with the name of the lowest active PID - though this may not actually be the main process if (handles.size() > 0) m_UserInterface->setProcessName(QString::fromStdWString(getProcessName(handles.begin()->second))); + // If the main wait process dies, we need a backup wait process until the subprocesses close if ((res == WAIT_FAILED) || (res == WAIT_OBJECT_0)) { if (handles.size() > 0) { - QThread::msleep(500); + // By the time we get here, the main wait function should always immediately continue + // Passing in a handle doesn't seem to work for subprocesses + ::MsgWaitForMultipleObjects(0, NULL, FALSE, 500, QS_KEY | QS_MOUSE); } } - // If process handle is still closed, let's give it one more try... + // Give the process list a short time to populate + // Required for initial USVFS boot and process switching if (handles.size() == 0 && !found) { - // it's possible the previous process has deregistered before - // the new one has registered, so we should try one more time - // with a little delay if (tryAgain) { tryAgain = false; QThread::msleep(500); -- cgit v1.3.1 From 4cd09a2f3b25c1af5939f5de0153b1438241a874 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Sun, 5 Nov 2017 14:03:02 -0600 Subject: Wait for mousebutton to reduce MO cpu use while waiting --- src/organizercore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/organizercore.cpp') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index d12b77b9..f8a368c9 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1260,7 +1260,7 @@ bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode) // Wait for a an event on the handle, a key press, mouse click or timeout while ( res = ::MsgWaitForMultipleObjects(1, &handle, false, 500, - QS_KEY | QS_MOUSE), + QS_KEY | QS_MOUSEBUTTON), ((m_UserInterface == nullptr) || !m_UserInterface->unlockClicked())) { if (!::GetVFSProcessList(&numProcesses, processes)) { @@ -1311,7 +1311,7 @@ bool OrganizerCore::waitForProcessCompletion(HANDLE handle, LPDWORD exitCode) if (handles.size() > 0) { // By the time we get here, the main wait function should always immediately continue // Passing in a handle doesn't seem to work for subprocesses - ::MsgWaitForMultipleObjects(0, NULL, FALSE, 500, QS_KEY | QS_MOUSE); + ::MsgWaitForMultipleObjects(0, NULL, FALSE, 500, QS_KEY | QS_MOUSEBUTTON); } } -- cgit v1.3.1