]> git.lyx.org Git - lyx.git/blobdiff - src/support/Systemcall.cpp
Add new placeholder $${python} to configure
[lyx.git] / src / support / Systemcall.cpp
index d0ff9ae993f1111bad555976db32d16d992f3d24..6c96de1644792ba4038ecfe8dde6b67438edb937 100644 (file)
@@ -59,22 +59,22 @@ class ProgressDummy : public ProgressInterface
 public:
        ProgressDummy() {}
 
-       void processStarted(QString const &) {}
-       void processFinished(QString const &) {}
-       void appendMessage(QString const &) {}
-       void appendError(QString const &) {}
-       void clearMessages() {}
-       void lyxerrFlush() {}
-
-       void lyxerrConnect() {}
-       void lyxerrDisconnect() {}
-
-       void warning(QString const &, QString const &) {}
-       void toggleWarning(QString const &, QString const &, QString const &) {}
-       void error(QString const &, QString const &, QString const &) {}
-       void information(QString const &, QString const &) {}
+       void processStarted(QString const &) override {}
+       void processFinished(QString const &) override {}
+       void appendMessage(QString const &) override {}
+       void appendError(QString const &) override {}
+       void clearMessages() override {}
+       void lyxerrFlush() override {}
+
+       void lyxerrConnect() override {}
+       void lyxerrDisconnect() override {}
+
+       void warning(QString const &, QString const &) override {}
+       void toggleWarning(QString const &, QString const &, QString const &) override {}
+       void error(QString const &, QString const &, QString const &) override {}
+       void information(QString const &, QString const &) override {}
        int prompt(docstring const &, docstring const &, int default_but, int,
-                  docstring const &, docstring const &) { return default_but; }
+                  docstring const &, docstring const &) override { return default_but; }
 };
 
 
@@ -169,7 +169,7 @@ string const parsecmd(string const & incmd, string & infile, string & outfile,
        bool in_single_quote = false;
        bool in_double_quote = false;
        bool escaped = false;
-       string const python_call = "python -tt";
+       string const python_call = os::python();
        vector<string> outcmd(4);
        size_t start = 0;
 
@@ -368,6 +368,23 @@ void SystemcallPrivate::startProcess(QString const & cmd, string const & path,
                                      string const & lpath, bool detached)
 {
        cmd_ = cmd;
+#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.
+       */
+       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
@@ -379,7 +396,11 @@ void SystemcallPrivate::startProcess(QString const & cmd, string const & path,
                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;
                }
@@ -387,7 +408,11 @@ void SystemcallPrivate::startProcess(QString const & cmd, string const & path,
                delete released;
        } else if (process_) {
                state = SystemcallPrivate::Starting;
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
+               process_->start(command, arguments);
+#else
                process_->start(toqstr(latexEnvCmdPrefix(path, lpath)) + cmd_);
+#endif
        }
 }
 
@@ -440,7 +465,7 @@ bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int time
                        while (!timedout) {
                                if (process_->waitForFinished(timeout))
                                        return true;
-                               bool stop = queryStopCommand(cmd_);
+                               bool const stop = queryStopCommand(cmd_);
                                // The command may have finished in the meantime
                                if (process_->state() == QProcess::NotRunning)
                                        return true;
@@ -475,7 +500,7 @@ bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int time
                        return false;
 
                if (timer.elapsed() > timeout) {
-                       bool stop = queryStopCommand(cmd_);
+                       bool const stop = queryStopCommand(cmd_);
                        // The command may have finished in the meantime
                        if (process_->state() == QProcess::NotRunning)
                                break;