commit c81bb47e49414ed5b6289f184f27349a5afda5f0
Author: Scott Kostyshak <[email protected]>
Date: Wed Nov 25 15:34:07 2020 -0500
Catch exception if LaTeX fails for child preview
The exception is raised when an included file fails to export
because e.g. it is from a newer version of LyX or because an
intermediate command such as knitr fails.
The exception was introduced at 1a374a93 so that the export of a
document exits with error if an included document exports with
error.
This commit catches the exception when the LaTeX is asked for in
order to generate a preview of the included file.
---
src/insets/InsetInclude.cpp | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index 07f5eec..bf9e1f5 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -1308,7 +1308,19 @@ void add_preview(RenderMonitoredPreview & renderer,
InsetInclude const & inset,
InsetCommandParams const & params = inset.params();
if (RenderPreview::previewText() && preview_wanted(params, buffer)) {
renderer.setAbsFile(includedFileName(buffer, params));
- docstring const snippet = latexString(inset);
+ docstring snippet;
+ try {
+ // InsetInclude::latex() throws if generation of LaTeX
+ // fails, e.g. if lyx2lyx fails because file is too
+ // new, or knitr fails.
+ snippet = latexString(inset);
+ } catch (...) {
+ // remove current preview because it is likely
+ // associated with the previous included file name
+ renderer.removePreview(buffer);
+ LYXERR0("Preview of include failed.");
+ return;
+ }
renderer.addPreview(snippet, buffer);
}
}
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs