Angus Leeming <[EMAIL PROTECTED]> writes:
| Oh, purlease! (this of course means "it works on my computer!")
|
| One is derived from the other, so it should work. However, this code is
| really ugly and really lazy. I'll fix it properly. In the meantime you could
| try an explicit cast:
|
| if (it ==
| static_cast<vector<NamedColor>::const_iterator>(xformColorDB.end())) {
|
| Incidentally, you could always modify your own lyxconfig.m4 to remove
| -finline and get rid of those irritating warnings.
I just removed the const_cast altogether, and changed xformColorDB and
lyxColorCB to mutable. I also did some resttructering to avoid using
the same type on two different types...
Remember, there is a reason why C++ casts are so ugly. (Avoid Them!
Avoid Them! Avoid Them!)
[Initially my comment was:
_why_ do you need the cast at all, and _why_ there? If the cast is
really needed you should cast the _container_ and not the resulting
iterator. And absolutely not converting it to another type of
iterator. (why do you need that anyway?)]
Lgb
Index: FormPreferences.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormPreferences.C,v
retrieving revision 1.40
diff -u -p -r1.40 FormPreferences.C
--- FormPreferences.C 2000/11/21 15:46:10 1.40
+++ FormPreferences.C 2000/11/21 17:37:51
@@ -966,28 +966,30 @@ bool FormPreferences::Colors::Modify() c
string const name = fl_get_browser_line(dialog_->browser_lyx_objs, i);
+ // Ok! Modify the color.
+ int const j = fl_get_browser(dialog_->browser_x11);
+ if (j < 1) return true;
+
// Is the choice an Xforms color...
- vector<NamedColor>::iterator it = // non-const; it's modified below
- const_cast<vector<XformColor>::iterator>(
+ vector<XformColor>::iterator it =
find_if(xformColorDB.begin(), xformColorDB.end(),
- compare_memfun(&NamedColor::getname, name)));
+ compare_memfun(&NamedColor::getname, name));
// or a LyX Logical color?
- if (it == xformColorDB.end()) {
- it = const_cast<vector<NamedColor>::iterator>(
+ if (it != xformColorDB.end()) {
+ (*it).r = colorDB[j - 1].r;
+ (*it).g = colorDB[j - 1].g;
+ (*it).b = colorDB[j - 1].b;
+ } else {
+ vector<NamedColor>::iterator it =
find_if(lyxColorDB.begin(), lyxColorDB.end(),
- compare_memfun(&NamedColor::getname, name)));
+ compare_memfun(&NamedColor::getname, name));
if (it == lyxColorDB.end()) return true;
+ (*it).r = colorDB[j - 1].r;
+ (*it).g = colorDB[j - 1].g;
+ (*it).b = colorDB[j - 1].b;
}
- // Ok! Modify the color.
- int const j = fl_get_browser(dialog_->browser_x11);
- if (j < 1) return true;
-
- (*it).r = colorDB[j - 1].r;
- (*it).g = colorDB[j - 1].g;
- (*it).b = colorDB[j - 1].b;
-
fl_freeze_form(dialog_->form);
fl_deselect_browser(dialog_->browser_x11);
Index: FormPreferences.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormPreferences.h,v
retrieving revision 1.33
diff -u -p -r1.33 FormPreferences.h
--- FormPreferences.h 2000/11/21 15:46:11 1.33
+++ FormPreferences.h 2000/11/21 17:37:51
@@ -200,9 +200,9 @@ private:
static std::vector<NamedColor> colorDB;
/// A vector of LyX LColor GUI name and associated RGB color.
- std::vector<NamedColor> lyxColorDB;
+ mutable std::vector<NamedColor> lyxColorDB;
/// A vector of xform color ID, RGB colors and associated name.
- std::vector<XformColor> xformColorDB;
+ mutable std::vector<XformColor> xformColorDB;
};
///
friend class Colors;