MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / postRun

Method postRun

src/processrunner.cpp:843–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

841}
842
843ProcessRunner::Results ProcessRunner::postRun()
844{
845 const bool mustWait = (m_waitFlags & ForceWait);
846
847 if (!m_sp.hooked && !mustWait) {
848 // the process wasn't hooked and there's no force wait, don't lock
849 return Running;
850 }
851
852 if (mustWait && m_lockReason == UILocker::NoReason) {
853 // never lock the ui without an escape hatch for the user
854 log::debug("the ForceWait flag is set but the lock reason wasn't, "
855 "defaulting to LockUI");
856
857 m_lockReason = UILocker::LockUI;
858 }
859
860 const bool lockEnabled = m_core.settings().interface().lockGUI();
861
862 if (mustWait) {
863 if (!lockEnabled) {
864 // at least tell the user what's going on
865 log::debug("locking is disabled, but the output of the application is required; "
866 "overriding this setting and locking the ui");
867 }
868 } else {
869 // no force wait
870
871 if (m_lockReason == UILocker::NoReason) {
872 // no locking requested
873 return Running;
874 }
875
876 if (!lockEnabled) {
877 // disabling locking is like clicking on unlock immediately
878 log::debug("process runner: not waiting for process because "
879 "locking is disabled");
880
881 return ForceUnlocked;
882 }
883 }
884
885 auto r = Error;
886
887 if (mustWait && m_lockReason == UILocker::PreventExit && !lockEnabled) {
888 // this happens when running shortcuts and locking is disabled
889 //
890 // MO must stay alive until all processes are dead or child processes
891 // may not get hooked properly, but the user has disabled locking the ui
892 //
893 // this is a bit of an edge case, but that means the user wants to run
894 // shortcuts without seeing the lock dialog, so allow them to do that
895 //
896 // MO will be running in the background with no visual feedback, but that's
897 // how it is
898 r = waitForProcess(m_handle.get(), &m_exitCode, nullptr);
899 } else {
900 withLock([&](auto& ls) {

Callers

nothing calls this directly

Calls 6

waitForProcessFunction · 0.85
lockGUIMethod · 0.80
afterRunMethod · 0.80
settingsMethod · 0.45
getMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected