[LyX/2.4.x] Fixup b29b3eb1: fix broken xml syntax

Jean-Marc Lasgouttes lasgouttes at lyx.org
Wed Jul 24 16:18:04 UTC 2024


commit 8ea0987644eae6f6ec2e5eff308feded4ef51f3e
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Tue Jul 23 15:04:49 2024 +0200

    Fixup b29b3eb1: fix broken xml syntax
    
    This commit addresses two issues:
    
    1/ the embarassing one: the member SetMode::old_text_level_ was
       declared as bool instead of int. This means that is was definitely
       not a proper backup variable!
    
    2/ a robustness issue: replace two consecutive test for isTest() by a
       boolean veriable that is used twice. This makes sure that <mrow>
       cannot be output without the corresponding </mrow>.
    
    Part of bug #13069.
    
    (cherry picked from commit a268fe096a58a7818554a7da4da85896bb289c81)
---
 src/mathed/MathExtern.cpp | 6 ++++--
 src/mathed/MathStream.h   | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 1f9356f8f2..990d35e9d2 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -1646,11 +1646,13 @@ void mathmlize(MathData const & dat, MathMLStream & ms)
 	} else if (ar.size() == 1) {
 		ms << ar.front();
 	} else {
-		if (!ms.inText())
+		// protect against the value changing in the second test.
+		bool const intext = ms.inText();
+		if (!intext)
 			ms << MTag("mrow");
 		for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
 			(*it)->mathmlize(ms);
-		if (!ms.inText())
+		if (!intext)
 			ms << ETag("mrow");
 	}
 }
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index 0cf10f0061..ffa14a7b59 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -469,7 +469,7 @@ private:
 	///
 	MathMLStream & ms_;
 	///
-	bool old_text_level_;
+	int old_text_level_;
 };
 
 


More information about the lyx-cvs mailing list