commit c6b3f35c8c52e91a6dee568754d9962466f2e074
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Sun May 17 14:57:55 2020 -0400

    Properly check return values so TIMEOUT is recognized.
---
 src/Converter.cpp          |    6 +++---
 src/LaTeX.cpp              |   32 ++++++++++++++++----------------
 src/support/Systemcall.cpp |    5 +++--
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/Converter.cpp b/src/Converter.cpp
index cb98b44..0c541c8 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -595,8 +595,8 @@ Converters::RetVal Converters::convert(Buffer const * 
buffer,
                        // FIXME KILLED
                        // Check changed return value here.
                        RetVal const retval = runLaTeX(*buffer, command, 
runparams, errorList);
-                               if (retval != SUCCESS)
-                                       return retval;
+                       if (retval != SUCCESS)
+                               return retval;
                } else {
                        if (conv.need_aux() && !run_latex) {
                                // We are not importing, we have a buffer
@@ -866,7 +866,7 @@ Converters::RetVal Converters::runLaTeX(Buffer const & 
buffer, string const & co
                });
        int const result = latex.run(terr);
 
-       if (result == Systemcall::KILLED) {
+       if (result == Systemcall::KILLED || result == Systemcall::TIMEOUT) {
                Alert::error(_("Export canceled"),
                        _("The export process was terminated by the user."));
                return KILLED;
diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp
index a34db97..81f8a39 100644
--- a/src/LaTeX.cpp
+++ b/src/LaTeX.cpp
@@ -281,16 +281,16 @@ int LaTeX::run(TeXErrors & terr)
        message(runMessage(count));
 
        int exit_code = startscript();
-       if (exit_code == Systemcall::KILLED)
-               return Systemcall::KILLED;
+       if (exit_code == Systemcall::KILLED || exit_code == Systemcall::TIMEOUT)
+               return exit_code;
 
        scanres = scanLogFile(terr);
        if (scanres & ERROR_RERUN) {
                LYXERR(Debug::LATEX, "Rerunning LaTeX");
                terr.clearErrors();
                exit_code = startscript();
-               if (exit_code == Systemcall::KILLED)
-                       return Systemcall::KILLED;
+               if (exit_code == Systemcall::KILLED || exit_code == 
Systemcall::TIMEOUT)
+                       return exit_code;
                scanres = scanLogFile(terr);
        }
 
@@ -322,8 +322,8 @@ int LaTeX::run(TeXErrors & terr)
                // onlyFileName() is needed for cygwin
                int const ret = 
                                
runMakeIndex(onlyFileName(idxfile.absFileName()), runparams);
-               if (ret == Systemcall::KILLED)
-                       return Systemcall::KILLED;
+               if (ret == Systemcall::KILLED || ret == Systemcall::TIMEOUT)
+                       return ret;
                FileName const ilgfile(changeExtension(file.absFileName(), 
".ilg"));
                if (ilgfile.exists())
                        iscanres = scanIlgFile(terr);
@@ -338,8 +338,8 @@ int LaTeX::run(TeXErrors & terr)
        // FIXME: Sort out the real problem in DepTable.
        if (head.haschanged(nlofile) || (nlofile.exists() && 
nlofile.isFileEmpty())) {
                int const ret = runMakeIndexNomencl(file, ".nlo", ".nls");
-               if (ret == Systemcall::KILLED)
-                       return Systemcall::KILLED;
+               if (ret == Systemcall::KILLED || ret == Systemcall::TIMEOUT)
+                       return ret;
                rerun = true;
        }
 
@@ -375,8 +375,8 @@ int LaTeX::run(TeXErrors & terr)
                updateBibtexDependencies(head, bibtex_info);
                int exit_code;
                rerun |= runBibTeX(bibtex_info, runparams, exit_code);
-               if (exit_code == Systemcall::KILLED)
-                       return Systemcall::KILLED;
+               if (exit_code == Systemcall::KILLED || exit_code == 
Systemcall::TIMEOUT)
+                       return exit_code;
                FileName const blgfile(changeExtension(file.absFileName(), 
".blg"));
                if (blgfile.exists())
                        bscanres = scanBlgFile(head, terr);
@@ -406,8 +406,8 @@ int LaTeX::run(TeXErrors & terr)
                LYXERR(Debug::LATEX, "Run #" << count);
                message(runMessage(count));
                int exit_code = startscript();
-               if (exit_code == Systemcall::KILLED)
-                       return Systemcall::KILLED;
+               if (exit_code == Systemcall::KILLED || exit_code == 
Systemcall::TIMEOUT)
+                       return exit_code;
                scanres = scanLogFile(terr);
 
                // update the depedencies
@@ -436,8 +436,8 @@ int LaTeX::run(TeXErrors & terr)
                updateBibtexDependencies(head, bibtex_info);
                int exit_code;
                rerun |= runBibTeX(bibtex_info, runparams, exit_code);
-               if (exit_code == Systemcall::KILLED)
-                       return Systemcall::KILLED;
+               if (exit_code == Systemcall::KILLED || exit_code == 
Systemcall::TIMEOUT)
+                       return exit_code;
                FileName const blgfile(changeExtension(file.absFileName(), 
".blg"));
                if (blgfile.exists())
                        bscanres = scanBlgFile(head, terr);
@@ -459,8 +459,8 @@ int LaTeX::run(TeXErrors & terr)
                // onlyFileName() is needed for cygwin
                int const ret = runMakeIndex(onlyFileName(changeExtension(
                                file.absFileName(), ".idx")), runparams);
-               if (ret == Systemcall::KILLED)
-                       return Systemcall::KILLED;
+               if (ret == Systemcall::KILLED || ret == Systemcall::TIMEOUT)
+                       return ret;
                FileName const ilgfile(changeExtension(file.absFileName(), 
".ilg"));
                if (ilgfile.exists())
                        iscanres = scanIlgFile(terr);
diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp
index d0ff9ae..8be8732 100644
--- a/src/support/Systemcall.cpp
+++ b/src/support/Systemcall.cpp
@@ -424,6 +424,7 @@ bool queryStopCommand(QString const & cmd)
 
 bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int 
timeout)
 {
+       timeout = 1000;
        if (!process_)
                return false;
 
@@ -440,7 +441,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 +476,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;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to