For some time, I have been annoyed by the fact that, when I load a file in lyx 1.4.0cvs, it appears in a random color. While the visual effect is probably the consequence of a nonunititalized variable on my particular setting (I have seen nobody reporting that), it is probably related to the bug about superfluous \textcolor{ } reported earlier by Kayvan.
After a too long hunt, I came up with the attached patch, which basically makes sure that we do not honor case in LyX Names for colors. The problem was coming from the 'Color "None"' (instead of "none") that can be found in our layout files. However, I do not understand the logic between the getLyXName() behaviour. After my patch, it reads: LColor::color LColor::getFromLyXName(string const & lyxname) const { string const lcname = ascii_lowercase(lyxname); if (pimpl_->transform.find(lcname) == pimpl_->transform.end()) { lyxerr << "LColor::getFromLyXName: Unknown color \"" << lyxname << '"' << endl; addColor(static_cast<color>(pimpl_->infotab.size()), lcname); } return static_cast<LColor::color>(pimpl_->transform[lcname]); } I really do not understand why the call to addColor has been added. Its effect is that, if I put a bogus 'Color "foo"' statement in a layout file, instead of correctly falling back to "none" or something, the code will create a new color "foo" which is not bound to anything useful, and will create havoc later. Angus, Martin, I see that these changes were related to the branches work. Could you tell me what it is good for? JMarc
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.1829 diff -u -p -r1.1829 ChangeLog --- src/ChangeLog 11 Mar 2004 16:09:32 -0000 1.1829 +++ src/ChangeLog 16 Mar 2004 14:40:07 -0000 @@ -1,3 +1,7 @@ +2004-03-16 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * LColor.C (getFromLyXName): make sure that the color name is used + as lowercase. 2004-03-11 André Pönitz <[EMAIL PROTECTED]> Index: src/LColor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LColor.C,v retrieving revision 1.50 diff -u -p -r1.50 LColor.C --- src/LColor.C 14 Dec 2003 16:33:51 -0000 1.50 +++ src/LColor.C 16 Mar 2004 14:40:07 -0000 @@ -24,6 +24,7 @@ #include <map> using lyx::support::compare_ascii_no_case; +using lyx::support::ascii_lowercase; using std::endl; using std::string; @@ -249,10 +250,14 @@ void LColor::addColor(LColor::color c, s LColor::color LColor::getFromLyXName(string const & lyxname) const { - if (pimpl_->transform.find(lyxname) == pimpl_->transform.end()) - addColor(static_cast<color>(pimpl_->infotab.size()), lyxname); + string const lcname = ascii_lowercase(lyxname); + if (pimpl_->transform.find(lcname) == pimpl_->transform.end()) { + lyxerr << "LColor::getFromLyXName: Unknown color \"" + << lyxname << '"' << endl; + addColor(static_cast<color>(pimpl_->infotab.size()), lcname); + } - return static_cast<LColor::color>(pimpl_->transform[lyxname]); + return static_cast<LColor::color>(pimpl_->transform[lcname]); }