Fix infinite loop when changing the color in the color picker on OS X

Originally committed to SVN as r6785.
This commit is contained in:
Thomas Goyne 2012-05-15 13:39:35 +00:00
parent 75305877f0
commit a97c7fa1f6

View file

@ -870,11 +870,17 @@ wxColour DialogColorPicker::GetColor()
return cur_color; return cur_color;
} }
static void change_value(wxSpinCtrl *ctrl, int value)
{
wxEventBlocker blocker(ctrl);
ctrl->SetValue(value);
}
void DialogColorPicker::SetRGB(unsigned char r, unsigned char g, unsigned char b) void DialogColorPicker::SetRGB(unsigned char r, unsigned char g, unsigned char b)
{ {
rgb_input[0]->SetValue(r); change_value(rgb_input[0], r);
rgb_input[1]->SetValue(g); change_value(rgb_input[1], g);
rgb_input[2]->SetValue(b); change_value(rgb_input[2], b);
cur_color = wxColour(r, g, b, wxALPHA_OPAQUE); cur_color = wxColour(r, g, b, wxALPHA_OPAQUE);
} }
@ -882,18 +888,18 @@ void DialogColorPicker::SetHSL(unsigned char r, unsigned char g, unsigned char b
{ {
unsigned char h, s, l; unsigned char h, s, l;
rgb_to_hsl(r, g, b, &h, &s, &l); rgb_to_hsl(r, g, b, &h, &s, &l);
hsl_input[0]->SetValue(h); change_value(hsl_input[0], h);
hsl_input[1]->SetValue(s); change_value(hsl_input[1], s);
hsl_input[2]->SetValue(l); change_value(hsl_input[2], l);
} }
void DialogColorPicker::SetHSV(unsigned char r, unsigned char g, unsigned char b) void DialogColorPicker::SetHSV(unsigned char r, unsigned char g, unsigned char b)
{ {
unsigned char h, s, v; unsigned char h, s, v;
rgb_to_hsv(r, g, b, &h, &s, &v); rgb_to_hsv(r, g, b, &h, &s, &v);
hsv_input[0]->SetValue(h); change_value(hsv_input[0], h);
hsv_input[1]->SetValue(s); change_value(hsv_input[1], s);
hsv_input[2]->SetValue(v); change_value(hsv_input[2], v);
} }
/// @brief Use the values entered in the RGB controls to update the other controls /// @brief Use the values entered in the RGB controls to update the other controls