| 34 | #endif |
| 35 | |
| 36 | void Process::start(const QString &program, const QStringList &arguments, const QString &path) |
| 37 | { |
| 38 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); |
| 39 | QString curPath = env.value("PATH"); |
| 40 | QString addPath = IDE::instance()->appDir(); |
| 41 | if (!path.isEmpty()) |
| 42 | addPath = path + pathSep + addPath; |
| 43 | env.insert("PATH", addPath + pathSep + curPath); |
| 44 | setProcessEnvironment(env); |
| 45 | #ifdef Q_OS_WIN |
| 46 | _wputenv_s(L"PATH", (addPath + pathSep + curPath).toStdWString().c_str()); |
| 47 | if (IsWindows8OrGreater()) { |
| 48 | jobObject = CreateJobObject(nullptr, nullptr); |
| 49 | connect(this, &QProcess::started, this, &Process::attachJob); |
| 50 | } else { |
| 51 | // Workaround PCA automatically adding to a job for Windows 7 |
| 52 | setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args) { |
| 53 | args->flags |= CREATE_BREAKAWAY_FROM_JOB; |
| 54 | }); |
| 55 | } |
| 56 | #else |
| 57 | #if QT_VERSION >= 0x060000 |
| 58 | setChildProcessModifier(Process::setpgid); |
| 59 | #endif |
| 60 | setenv("PATH", (addPath + pathSep + curPath).toStdString().c_str(), 1); |
| 61 | #endif |
| 62 | QProcess::start(program,arguments, QIODevice::Unbuffered | QIODevice::ReadWrite); |
| 63 | #ifdef Q_OS_WIN |
| 64 | _wputenv_s(L"PATH", curPath.toStdWString().c_str()); |
| 65 | #else |
| 66 | setenv("PATH", curPath.toStdString().c_str(), 1); |
| 67 | #endif |
| 68 | } |
| 69 | |
| 70 | void Process::terminate() |
| 71 | { |
no test coverage detected