mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Export/view a PDF even if error
A PDF is often still produced after a LaTeX error. If there was an error when exporting a PDF, we now give an error and the PDF (if it exists), where before we gave the error and not the PDF. The GUI and command line behaviors are consistent: in the GUI an error is given and the PDF is viewed; on the command line, a non-zero exit code is given and a PDF is created. This also solves what was in my mind an inconsistency: if the user "updated" a document and there was an error, the resulting PDF would be shown; but if the user viewed a document and there was an error, the document would not be shown. Note that this applies to all output formats, not just PDF. For discussion, see: https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg186454.html
This commit is contained in:
parent
0a6120cb7f
commit
cd8be655f1
@ -4119,12 +4119,10 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
|
||||
d->cloned_buffer_->d->errorLists[error_type] = d->errorLists[error_type];
|
||||
}
|
||||
|
||||
if (!success)
|
||||
return ExportConverterError;
|
||||
|
||||
if (put_in_tempdir) {
|
||||
result_file = tmp_result_file.absFileName();
|
||||
return ExportSuccess;
|
||||
return success ? ExportSuccess : ExportConverterError;
|
||||
}
|
||||
|
||||
if (dest_filename.empty())
|
||||
@ -4189,7 +4187,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
|
||||
formats.prettyName(format)));
|
||||
}
|
||||
|
||||
return ExportSuccess;
|
||||
return success ? ExportSuccess : ExportConverterError;
|
||||
}
|
||||
|
||||
|
||||
@ -4214,11 +4212,10 @@ Buffer::ExportStatus Buffer::preview(string const & format, bool includeall) con
|
||||
}
|
||||
// (2) export with included children only
|
||||
ExportStatus const status = doExport(format, true, false, result_file);
|
||||
if (status != ExportSuccess)
|
||||
return status;
|
||||
if (!formats.view(*this, FileName(result_file), format))
|
||||
FileName const previewFile(result_file);
|
||||
if (previewFile.exists() && !formats.view(*this, previewFile, format))
|
||||
return PreviewError;
|
||||
return PreviewSuccess;
|
||||
return (status == ExportSuccess) ? PreviewSuccess : status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,6 +110,10 @@ LaTeX::LaTeX(string const & latex, OutputParams const & rp,
|
||||
|
||||
void LaTeX::deleteFilesOnError() const
|
||||
{
|
||||
// Note that we do not always call this function when there is an error.
|
||||
// For example, if there is an error but an output file is produced we
|
||||
// still would like to output (export/view) the file.
|
||||
|
||||
// What files do we have to delete?
|
||||
|
||||
// This will at least make latex do all the runs
|
||||
@ -236,7 +240,9 @@ int LaTeX::run(TeXErrors & terr)
|
||||
}
|
||||
|
||||
if (scanres & ERRORS) {
|
||||
deleteFilesOnError();
|
||||
// We no longer run deleteFilesOnError() here
|
||||
// because we now show a resulting PDF even if
|
||||
// there was an error.
|
||||
return scanres; // return on error
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user