From c61472303e4ea1d59d1f26e9d4a516dd2c50feb2 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak Date: Sun, 8 Dec 2019 19:14:38 -0500 Subject: [PATCH] Fix crash due to encoding issues with child doc This crash occurred starting with 553bebc3, and can be triggered when preview is enabled both in preferences and in a child document inset. For a minimal example, see the following ML thread: https://www.mail-archive.com/search?l=mid&q=20191209002609.6fao3dljtf3ohl25%40tallinn This fix restores behavior to before that commit for the case when oldEnc is 0. --- src/insets/InsetInclude.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 3cf318906f..1bd1c5ba02 100755 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -848,8 +848,11 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const Language const * const oldLang = runparams.master_language; // If the master uses non-TeX fonts (XeTeX, LuaTeX), // the children must be encoded in plain utf8! - runparams.encoding = masterBuffer->params().useNonTeXFonts ? - encodings.fromLyXName("utf8-plain") : oldEnc; + if (masterBuffer->params().useNonTeXFonts) + runparams.encoding = encodings.fromLyXName("utf8-plain"); + else if (oldEnc) + runparams.encoding = oldEnc; + else runparams.encoding = &tmp->params().encoding(); runparams.master_language = buffer().params().language; runparams.par_begin = 0; runparams.par_end = tmp->paragraphs().size(); -- 2.39.2