From: Enrico Forestieri Date: Tue, 16 Jun 2009 21:22:32 +0000 (+0000) Subject: Reintroduce workaround due to nested math hulls as it is not X-Git-Tag: 2.0.0~6284 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4559c29eebb1ed89d303ffd1c9031da2e0e28663;p=features.git Reintroduce workaround due to nested math hulls as it is not guaranteed that LyX is always able to replace $...$ constructs with \ensuremath{...}. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30145 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index b773b088c6..259152000d 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -450,7 +450,14 @@ void InsetMathHull::drawT(TextPainter & pain, int x, int y) const static docstring latexString(InsetMathHull const & inset) { odocstringstream ls; - Encoding const * encoding = &(inset.buffer().params().encoding()); + // This has to be static, because a preview snippet or a math + // macro containing math in text mode (such as $\text{$\phi$}$ or + // \newcommand{\xxx}{\text{$\phi$}}) gets processed twice. The + // first time as a whole, and the second time only the inner math. + // In this last case inset.buffer() would be invalid. + static Encoding const * encoding = 0; + if (inset.isBufferValid()) + encoding = &(inset.buffer().params().encoding()); WriteStream wi(ls, false, true, false, encoding); inset.write(wi); return ls.str();