]> git.lyx.org Git - features.git/commitdiff
Do not crash with uncodable character in math preview snippert (part of #11855)
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 1 Dec 2022 15:01:38 +0000 (16:01 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 1 Dec 2022 15:01:38 +0000 (16:01 +0100)
src/mathed/InsetMathHull.cpp

index 0ab06d27be34854c2272b19bb2b2f8fb7778371b..f5dce8088492f6f4a3cb502b43af37ceb93f7405 100644 (file)
@@ -709,7 +709,20 @@ static docstring latexString(InsetMathHull const & inset)
        otexrowstream ots(ls);
        TeXMathStream wi(ots, false, true, TeXMathStream::wsPreview, encoding);
        inset.write(wi);
-       return ls.str();
+       docstring const s = ls.str();
+       docstring res;
+       for (char_type c : s) {
+           if (encoding->encodable(c))
+                   res += c;
+           else {
+                   // indicate the encoding error by a boxed '?'
+                   res += "{\\fboxsep=1pt\\fbox{?}}";
+                   LYXERR0("Uncodable character" << " '"
+                           << c
+                           << "'");
+           }
+       }
+       return res;
 }