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.
This commit is contained in:
Scott Kostyshak 2019-12-08 19:14:38 -05:00
parent 2e784b2f06
commit c61472303e

View File

@ -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();