- if (process_) {
- if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
- string const texinputs = os::latex_path_list(
- replaceCurdirPath(path, lyxrc.texinputs_prefix));
- string const sep = string(1,
- os::path_separator(os::TEXENGINE));
- string const prefix = "." + sep + texinputs + sep;
- if (prefixIs(texinputs_, prefix))
- texinputs_.clear();
- else
- setEnv("TEXINPUTS", prefix + texinputs_);
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
+ // FIXME pass command and arguments separated in the first place
+ /* The versions of startDetached() and start() that accept a
+ * QStringList object exist since Qt4, but it is only in Qt 5.15
+ * that splitCommand() was introduced and the plain versions of
+ * start/startDetached() have been deprecated.
+ * The cleanest solution would be to have parsecmd() produce a
+ * QStringList for arguments, instead of transforming the string
+ * into something that the QProcess splitter accepts.
+ *
+ * Another reason for doing that is that the Qt parser ignores
+ * empty "" arguments, which are needed in some instances (see
+ * e.g. the work around for modules in Converter:convert. See
+ * QTBUG-80640 for a discussion.
+ */
+ QStringList arguments = QProcess::splitCommand(toqstr(latexEnvCmdPrefix(path, lpath)) + cmd_);
+ QString command = (arguments.empty()) ? QString() : arguments.first();
+ if (arguments.size() == 1)
+ arguments.clear();
+ else if (!arguments.empty())
+ arguments.removeFirst();
+#endif
+ if (detached) {
+ state = SystemcallPrivate::Running;
+#ifdef Q_OS_WIN32
+ // Avoid opening a console window when a viewer is started
+ if (in_file_.empty())
+ process_->setStandardInputFile(QProcess::nullDevice());
+ if (out_file_.empty())
+ process_->setStandardOutputFile(QProcess::nullDevice());
+ if (err_file_.empty())
+ process_->setStandardErrorFile(QProcess::nullDevice());
+#endif
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
+ if (!QProcess::startDetached(command, arguments)) {
+#else
+ if (!QProcess::startDetached(toqstr(latexEnvCmdPrefix(path, lpath)) + cmd_)) {
+#endif
+ state = SystemcallPrivate::Error;
+ return;