]> git.lyx.org Git - lyx.git/commit
Fix crash when generating MathML with InsetMathBox
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 20 Jul 2024 10:15:32 +0000 (12:15 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 22 Jul 2024 18:53:29 +0000 (20:53 +0200)
commit216a6fb348dedac3230f651287a0ccfb48b88818
tree175934bd58c207916d6d5cfdb6d5054006cc5b5a
parentfbd4b0a13fae4263cc88aa76bc4fbba5178b15fa
Fix crash when generating MathML with InsetMathBox

Instead of generating code and parsing it to add <mtext>...</mtext> at
the right spots, this commit honors the text mode setting that was
already present in the codebase to generate it automatically.

This is the work of two helper methods in MathMLStream:

* beforeText() notices when the stream is in text mode and that a
  <mtext> has not yet been generated. In this case it inserts it, so
  that raw text can be emitted afterwards.

* beforeTag() checks whether a <mtext> needs to be closed at this
  point, and does it if needed.

To make this work, the code now tracks the nesting level in the
stream, and compares it the what the level was when text mode has been
enabled using the SetMode helper function.

In order to avoid later bugs, member os() that allows to access the
underlying stream of MathMLStream is removed. This required many <<
operators to become friends of MathMLStream.

In InsetMathBox, rename splitAndWrapInMText() to mathmlizeHelper(),
which is not just a method that sets text mode inside a <mrow>
element.

In InsetMathFont and InsetMathHull, the explicit generation of nesting
in <mtext>...</mtext> can be removed now.

Fixes bug #13069.
src/mathed/InsetMath.cpp
src/mathed/InsetMathBox.cpp
src/mathed/InsetMathFont.cpp
src/mathed/InsetMathHull.cpp
src/mathed/MathStream.cpp
src/mathed/MathStream.h