mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 00:38:01 +00:00
Allow LaTeX processes to be canceled.
This commit is contained in:
parent
cf782dfc68
commit
12b03b30f4
@ -810,7 +810,7 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
|
|||||||
string const name = buffer.latexName();
|
string const name = buffer.latexName();
|
||||||
LaTeX latex(command, runparams, FileName(makeAbsPath(name)),
|
LaTeX latex(command, runparams, FileName(makeAbsPath(name)),
|
||||||
buffer.filePath(), buffer.layoutPos(),
|
buffer.filePath(), buffer.layoutPos(),
|
||||||
buffer.lastPreviewError());
|
buffer.isClone(), buffer.lastPreviewError());
|
||||||
TeXErrors terr;
|
TeXErrors terr;
|
||||||
// The connection closes itself at the end of the scope when latex is
|
// The connection closes itself at the end of the scope when latex is
|
||||||
// destroyed. One cannot close (and destroy) buffer while the converter is
|
// destroyed. One cannot close (and destroy) buffer while the converter is
|
||||||
|
@ -93,9 +93,10 @@ bool operator!=(AuxInfo const & a, AuxInfo const & o)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LaTeX::LaTeX(string const & latex, OutputParams const & rp,
|
LaTeX::LaTeX(string const & latex, OutputParams const & rp,
|
||||||
FileName const & f, string const & p, string const & lp,
|
FileName const & f, string const & p, string const & lp,
|
||||||
bool const clean_start)
|
bool allow_cancellation, bool const clean_start)
|
||||||
: cmd(latex), file(f), path(p), lpath(lp), runparams(rp), biber(false)
|
: cmd(latex), file(f), path(p), lpath(lp), runparams(rp), biber(false),
|
||||||
|
allow_cancel(allow_cancellation)
|
||||||
{
|
{
|
||||||
num_errors = 0;
|
num_errors = 0;
|
||||||
// lualatex can still produce a DVI with --output-format=dvi. However,
|
// lualatex can still produce a DVI with --output-format=dvi. However,
|
||||||
@ -244,12 +245,16 @@ int LaTeX::run(TeXErrors & terr)
|
|||||||
message(runMessage(count));
|
message(runMessage(count));
|
||||||
|
|
||||||
int exit_code = startscript();
|
int exit_code = startscript();
|
||||||
|
if (exit_code == Systemcall::KILLED)
|
||||||
|
return Systemcall::KILLED;
|
||||||
|
|
||||||
scanres = scanLogFile(terr);
|
scanres = scanLogFile(terr);
|
||||||
if (scanres & ERROR_RERUN) {
|
if (scanres & ERROR_RERUN) {
|
||||||
LYXERR(Debug::LATEX, "Rerunning LaTeX");
|
LYXERR(Debug::LATEX, "Rerunning LaTeX");
|
||||||
terr.clearErrors();
|
terr.clearErrors();
|
||||||
exit_code = startscript();
|
exit_code = startscript();
|
||||||
|
if (exit_code == Systemcall::KILLED)
|
||||||
|
return Systemcall::KILLED;
|
||||||
scanres = scanLogFile(terr);
|
scanres = scanLogFile(terr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +344,9 @@ int LaTeX::run(TeXErrors & terr)
|
|||||||
LYXERR(Debug::DEPEND, "Dep. file has changed or rerun requested");
|
LYXERR(Debug::DEPEND, "Dep. file has changed or rerun requested");
|
||||||
LYXERR(Debug::LATEX, "Run #" << count);
|
LYXERR(Debug::LATEX, "Run #" << count);
|
||||||
message(runMessage(count));
|
message(runMessage(count));
|
||||||
startscript();
|
int exitCode = startscript();
|
||||||
|
if (exitCode == Systemcall::KILLED)
|
||||||
|
return Systemcall::KILLED;
|
||||||
scanres = scanLogFile(terr);
|
scanres = scanLogFile(terr);
|
||||||
|
|
||||||
// update the depedencies
|
// update the depedencies
|
||||||
@ -442,7 +449,9 @@ int LaTeX::startscript()
|
|||||||
+ quoteName(onlyFileName(file.toFilesystemEncoding()))
|
+ quoteName(onlyFileName(file.toFilesystemEncoding()))
|
||||||
+ " > " + os::nulldev();
|
+ " > " + os::nulldev();
|
||||||
Systemcall one;
|
Systemcall one;
|
||||||
return one.startscript(Systemcall::Wait, tmp, path, lpath);
|
Systemcall::Starttype const starttype =
|
||||||
|
allow_cancel ? Systemcall::WaitLoop : Systemcall::Wait;
|
||||||
|
return one.startscript(starttype, tmp, path, lpath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ public:
|
|||||||
support::FileName const & file,
|
support::FileName const & file,
|
||||||
std::string const & path = empty_string(),
|
std::string const & path = empty_string(),
|
||||||
std::string const & lpath = empty_string(),
|
std::string const & lpath = empty_string(),
|
||||||
|
bool allow_cancellation = false,
|
||||||
bool const clean_start = false);
|
bool const clean_start = false);
|
||||||
|
|
||||||
/// runs LaTeX several times
|
/// runs LaTeX several times
|
||||||
@ -242,9 +243,10 @@ private:
|
|||||||
|
|
||||||
/// Do we use biber?
|
/// Do we use biber?
|
||||||
bool biber;
|
bool biber;
|
||||||
|
|
||||||
///
|
///
|
||||||
std::vector <std::string> children;
|
std::vector <std::string> children;
|
||||||
|
///
|
||||||
|
bool allow_cancel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user