]> git.lyx.org Git - features.git/commitdiff
Fix crash due to encoding issues with child doc
authorScott Kostyshak <skostysh@lyx.org>
Mon, 9 Dec 2019 00:14:38 +0000 (19:14 -0500)
committerScott Kostyshak <skostysh@lyx.org>
Tue, 10 Dec 2019 14:17:49 +0000 (09:17 -0500)
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

index 3cf318906fb3912cd8a96a28f47193cd4fb90b3c..1bd1c5ba0283f0f9686cafb7f175b5069af4cb45 100755 (executable)
@@ -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();