Author: fabien
Date: 2009-01-21 08:09:39 -0800 (Wed, 21 Jan 2009)
New Revision: 6643
Log:
Fixed fl_color() setters would crash under X11 when called with no valid fl_gc.
The fix prefer not to set a default gc to avoid side unpredictable side effects
(i.e: the color would not be set on the expected window)
Maybe this could be later further improved by using
fl_GetGC() with the current or the first fltk window
so that a color would always be set.
Modified:
branches/branch-1.3/src/fl_color.cxx
Modified: branches/branch-1.3/src/fl_color.cxx
===================================================================
--- branches/branch-1.3/src/fl_color.cxx 2009-01-20 12:04:13 UTC (rev
6642)
+++ branches/branch-1.3/src/fl_color.cxx 2009-01-21 16:09:39 UTC (rev
6643)
@@ -167,10 +167,13 @@
The RGB color is used directly on TrueColor displays.
For colormap visuals the nearest index in the gray
ramp or color cube is used.
+ If no valid graphical context (fl_gc) is available,
+ the foreground is not set for the current window.
\param[in] r,g,b color components
*/
void fl_color(uchar r,uchar g,uchar b) {
fl_color_ = fl_rgb_color(r, g, b);
+ if(!fl_gc) return; // don't get a default gc if current window is not yet
created/valid
XSetForeground(fl_display, fl_gc, fl_xpixel(r,g,b));
}
@@ -321,6 +324,8 @@
For colormapped displays, a color cell will be allocated out of
\a fl_colormap the first time you use a color. If the colormap fills up
then a least-squares algorithm is used to find the closest color.
+ If no valid graphical context (fl_gc) is available,
+ the foreground is not set for the current window.
\param[in] i color
*/
void fl_color(Fl_Color i) {
@@ -329,6 +334,7 @@
fl_color((uchar)(rgb >> 24), (uchar)(rgb >> 16), (uchar)(rgb >> 8));
} else {
fl_color_ = i;
+ if(!fl_gc) return; // don't get a default gc if current window is not yet
created/valid
XSetForeground(fl_display, fl_gc, fl_xpixel(i));
}
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit