| 754 | } |
| 755 | |
| 756 | std::optional<ProcessRunner::Results> ProcessRunner::runBinary() |
| 757 | { |
| 758 | if (m_profileName.isEmpty()) { |
| 759 | // get the current profile name if it wasn't overridden |
| 760 | const auto* profile = m_core.currentProfile(); |
| 761 | if (!profile) { |
| 762 | throw MyException(QObject::tr("No profile set")); |
| 763 | } |
| 764 | |
| 765 | m_profileName = profile->name(); |
| 766 | } |
| 767 | |
| 768 | // saves profile, sets up usvfs, notifies plugins, etc.; can return false if |
| 769 | // a plugin doesn't want the program to run (such as when checkFNIS fails to |
| 770 | // run FNIS and the user clicks cancel) |
| 771 | if (!m_core.beforeRun(m_sp.binary, m_sp.currentDirectory, m_sp.arguments, |
| 772 | m_profileName, m_customOverwrite, m_forcedLibraries)) { |
| 773 | return Error; |
| 774 | } |
| 775 | |
| 776 | // parent widget used for any dialog popped up while checking for things |
| 777 | QWidget* parent = (m_ui ? m_ui->mainWindow() : nullptr); |
| 778 | |
| 779 | const auto* game = m_core.managedGame(); |
| 780 | auto& settings = m_core.settings(); |
| 781 | |
| 782 | // start steam if needed |
| 783 | if (!checkSteam(parent, m_sp, game->gameDirectory(), m_sp.steamAppID, settings)) { |
| 784 | return Error; |
| 785 | } |
| 786 | |
| 787 | // warn if the executable is on the blacklist |
| 788 | if (!checkBlacklist(parent, m_sp, settings)) { |
| 789 | return Error; |
| 790 | } |
| 791 | |
| 792 | // if the executable is inside the mods folder another instance of |
| 793 | // ModOrganizer.exe is spawned instead to launch it |
| 794 | adjustForVirtualized(game, m_sp, settings); |
| 795 | |
| 796 | // run the binary |
| 797 | m_handle.reset(startBinary(parent, m_sp)); |
| 798 | if (m_handle.get() == INVALID_HANDLE_VALUE) { |
| 799 | return Error; |
| 800 | } |
| 801 | |
| 802 | return {}; |
| 803 | } |
| 804 | |
| 805 | bool ProcessRunner::shouldRefresh(Results r) const |
| 806 | { |
nothing calls this directly
no test coverage detected