summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2009-01-21 16:09:39 +0000
committerFabien Costantini <fabien@onepost.net>2009-01-21 16:09:39 +0000
commit0e6409c3a0a6a002a9cc2d47cc18d550126f97dd (patch)
treef3ad6e896652bb51506a77095ad08cc645080c35 /src
parentecf26b1d12d81ffbacff2787da89687380af4bed (diff)
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. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6643 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_color.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/fl_color.cxx b/src/fl_color.cxx
index 98a715282..6e4a708f4 100644
--- a/src/fl_color.cxx
+++ b/src/fl_color.cxx
@@ -167,10 +167,13 @@ ulong fl_xpixel(uchar r,uchar g,uchar b) {
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 @@ Fl_Color fl_color_;
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 @@ void fl_color(Fl_Color i) {
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));
}
}