[LyX/master] Assure correct spacing of colored items in mathed

Enrico Forestieri forenr at lyx.org
Sun Feb 7 08:37:57 UTC 2021


On Sat, Feb 06, 2021 at 11:06:41PM -0500, Scott Kostyshak wrote:
> I see an assertion on master that I think started happening with this commit.
> 
> Here's the assertion:
> ASSERTION false VIOLATED IN /home/scott/lyxbuilds/master/repo/src/mathed/MathClass.cpp:59
> 
> The assertion happens when I just open the attached file.
> 
> Can you reproduce?

Yes, I can. Thanks for the report. Attached you find two patches.

The first is the right one, IMHO, but JMarc should tell whether the
"LATEST(false);" has to remain, instead (note that the assertion only
triggers in devel mode and is ignored in release mode).

The second one is to be used if the first one cannot be applied. This
patch simply assigns the string "mathord" that would be assigned without
the assert in class_to_string().

-- 
Enrico
-------------- next part --------------
diff --git a/src/mathed/MathClass.cpp b/src/mathed/MathClass.cpp
index 1d352cd746..98ab22e45c 100644
--- a/src/mathed/MathClass.cpp
+++ b/src/mathed/MathClass.cpp
@@ -56,7 +56,6 @@ docstring const class_to_string(MathClass const mc)
 		s = "mathinner";
 		break;
 	case MC_UNKNOWN:
-		LATTEST(false);
 		s = "mathord";
 	}
 	return from_ascii(s);
-------------- next part --------------
diff --git a/src/mathed/InsetMathColor.cpp b/src/mathed/InsetMathColor.cpp
index f2f9116bf9..5714fdec5e 100644
--- a/src/mathed/InsetMathColor.cpp
+++ b/src/mathed/InsetMathColor.cpp
@@ -99,10 +99,12 @@ void InsetMathColor::write(TeXMathStream & os) const
 	// We have to ensure correct spacing when the front and/or back
 	// atoms are not ordinary ones (bug 11827).
 	docstring const frontclass =
-		!cell(0).empty() ? class_to_string(cell(0).front()->mathClass())
+		!cell(0).empty() && cell(0).front()->mathClass() != MC_UNKNOWN
+		               ? class_to_string(cell(0).front()->mathClass())
 		               : from_ascii("mathord");
 	docstring const backclass =
-		!cell(0).empty() ? class_to_string(cell(0).back()->mathClass())
+		!cell(0).empty() && cell(0).front()->mathClass() != MC_UNKNOWN
+		               ? class_to_string(cell(0).back()->mathClass())
 		               : from_ascii("mathord");
 	bool adjchk = os.latex() && !os.inMathClass() && (normalcolor(color_) || oldstyle_);
 	bool adjust_front = frontclass != "mathord" && adjchk;


More information about the lyx-devel mailing list