#include <iostream>
#include <QProcess>
-#include <QTime>
+#include <QElapsedTimer>
#include <QThread>
#include <QCoreApplication>
#include <QDebug>
public:
ProgressDummy() {}
- void processStarted(QString const &) {}
- void processFinished(QString const &) {}
- void appendMessage(QString const &) {}
- void appendError(QString const &) {}
- void clearMessages() {}
- void lyxerrFlush() {}
+ 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() {}
- void lyxerrDisconnect() {}
+ void lyxerrConnect() override {}
+ void lyxerrDisconnect() override {}
- 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 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; }
};
-static ProgressInterface * progress_instance = 0;
+static ProgressInterface * progress_instance = nullptr;
void ProgressInterface::setInstance(ProgressInterface* p)
{
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;
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
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;
}
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
}
}
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;
}
// process events while waiting with timeout
- QTime timer;
+ QElapsedTimer timer;
timer.start();
while (state == waitwhile && state != Error && !timedout) {
// check for cancellation of background process
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;
QProcess* SystemcallPrivate::releaseProcess()
{
QProcess* released = process_;
- process_ = 0;
+ process_ = nullptr;
return released;
}