Fix external processes on Windows
This commit is contained in:
parent
7a4de9f3d9
commit
520bd7e6c8
1 changed files with 9 additions and 4 deletions
|
@ -2075,16 +2075,21 @@ void Editor::openProjectInTextEditor() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Editor::startDetachedProcess(const QString &command, const QString &workingDirectory, qint64 *pid) const {
|
bool Editor::startDetachedProcess(const QString &command, const QString &workingDirectory, qint64 *pid) const {
|
||||||
|
static QProcess process;
|
||||||
logInfo("Executing command: " + command);
|
logInfo("Executing command: " + command);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// On Windows, a QProcess command must be wrapped in a cmd.exe command.
|
// On Windows, a QProcess command must be wrapped in a cmd.exe command.
|
||||||
const QString program = QProcessEnvironment::systemEnvironment().value("COMSPEC");
|
process.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
||||||
QStringList arguments({ QString("/c"), command });
|
process.setProgram(process.processEnvironment().value("COMSPEC"));
|
||||||
|
process.setNativeArguments("/c " + command);
|
||||||
|
process.setWorkingDirectory(workingDirectory);
|
||||||
#else
|
#else
|
||||||
QStringList arguments = QProcess::splitCommand(command);
|
QStringList arguments = QProcess::splitCommand(command);
|
||||||
const QString program = arguments.takeFirst();
|
process.setProgram(arguments.takeFirst());
|
||||||
|
process.setArguments(arguments);
|
||||||
|
process.setWorkingDirectory(workingDirectory);
|
||||||
#endif
|
#endif
|
||||||
return QProcess::startDetached(program, arguments, workingDirectory, pid);
|
return process.startDetached(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It doesn't seem to be possible to prevent the mousePress event
|
// It doesn't seem to be possible to prevent the mousePress event
|
||||||
|
|
Loading…
Reference in a new issue