Dear Developers,

pending a decision about handling of text-mode commands in mathed, is it
OK to submit the following minimal-invasive patch to prevent the math
toolbars inserting symbols in a way that makes document uncompilable or
leads to wrong output?

Günter

>From 91d394e8484186d4d28d7098371261d41570c5fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=BCnter=20Milde?= <mi...@lyx.org>
Date: Wed, 7 Sep 2016 23:40:50 +0200
Subject: [PATCH] Fix math toolbars: do not insert text-mode commands in math
 mode.

* use ^\circ for a degree sign in math mode
   because \textdegree
  -  makes the document uncompilable with some input encodings
  -  gives wrong output (r-hachek) if textcomp is loaded (cf. #10349)

* wrap \lightning in \textrm
   - \lightning in math-mode prints an apostorphe
   - handle this similar to \AA and \O in the misc toolbar.
---
 lib/images/math/{textdegree.svgz => mathdegree.svgz} | Bin
 lib/ui/stdtoolbars.inc                               |   4 ++--
 src/frontends/qt4/GuiApplication.cpp                 |   4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)
 rename lib/images/math/{textdegree.svgz => mathdegree.svgz} (100%)

diff --git a/lib/images/math/textdegree.svgz b/lib/images/math/mathdegree.svgz
similarity index 100%
rename from lib/images/math/textdegree.svgz
rename to lib/images/math/mathdegree.svgz
diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc
index d375afa..da96766 100644
--- a/lib/ui/stdtoolbars.inc
+++ b/lib/ui/stdtoolbars.inc
@@ -681,7 +681,7 @@ ToolbarSet
                Item "textrm \\O" "math-insert \textrm \O"
                Item "mathcircumflex" "math-insert \mathcircumflex"
                Item "_" "math-insert \_"
-               Item "textdegree" "math-insert \textdegree"
+               Item "^\\circ" "math-insert ^\circ"
                Item "mathdollar" "math-insert \mathdollar"
                Item "mathparagraph" "math-insert \mathparagraph"
                Item "mathsection" "math-insert \mathsection"
@@ -793,7 +793,7 @@ ToolbarSet
                Item "eth" "math-insert \eth"
                Item "diagup" "math-insert \diagup"
                Item "diagdown" "math-insert \diagdown"
-               Item "lightning" "math-insert \lightning"
+               Item "textrm \\lightning" "math-insert \textrm \lightning"
                Item "varcopyright" "math-insert \varcopyright"
                Item "Bowtie" "math-insert \Bowtie"
                Item "diameter" "math-insert \diameter"
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 81d5373..7dd004e 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -301,6 +301,7 @@ private:
 // Please don't change the formatting, this list is parsed by
 // development/tools/generate_symbols_images.py.
 ImgMap sorted_img_map[] = {
+       { "\\circ", "mathdegree"}, // we use ^\circ for a degree sign in math 
mode
        { "Arrownot", "arrownot2"},
        { "Arrowvert", "arrowvert2"},
        { "Bowtie", "bowtie2" },
@@ -381,6 +382,7 @@ ImgMap sorted_img_map[] = {
        { "rvert", "vert" },
        { "textrm \\AA", "textrm_AA"},
        { "textrm \\O", "textrm_O"},
+       { "textrm \\lightning", "lightning"},
        { "vDash", "vdash2" },
        { "varDelta", "vardelta2" },
        { "varGamma", "vargamma2" },
@@ -592,7 +594,7 @@ QPixmap getPixmap(QString const & path, QString const & 
name, QString const & ex
        if (getPixmap(pixmap, fpath)) {
                return pixmap;
        }
-       
+
        QStringList exts = ext.split(",");
        fpath = ":/" + path + name + ".";
        for (int i = 0; i < exts.size(); ++i) {
-- 
2.9.3


Reply via email to