diff options
author | Hubert Jarosz <marqin.pl+git@gmail.com> | 2016-03-01 00:08:33 +0100 |
---|---|---|
committer | Hubert Jarosz <marqin.pl@gmail.com> | 2016-03-09 00:18:23 +0100 |
commit | 7b07bcaf449ea6cf52c2ac501e48cddbe4bde035 (patch) | |
tree | 5d5c2abcc801262b72f02f5e9c7c70a20c729e73 /scene/gui | |
parent | bf7f9244a95962c9833e68743726fe83a00b732c (diff) |
fix six possible "divide by zero"
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/color_picker.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index f8f8b1f6d1..bd24b43761 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -361,7 +361,10 @@ void ColorPicker::_preset_input(const InputEvent &ev) { emit_signal("color_changed", color); } else if (ev.type == InputEvent::MOUSE_MOTION) { const InputEventMouse &mev = ev.mouse_motion; - int index = mev.x/(preset->get_size().x/presets.size()); + int index = mev.x * presets.size(); + if( preset->get_size().x != 0 ) { + index /= preset->get_size().x; + } if (index<0 || index >= presets.size()) return; preset->set_tooltip("Color: #"+presets[index].to_html(presets[index].a<1)+"\n" @@ -684,4 +687,3 @@ ColorPickerButton::ColorPickerButton() { picker->connect("color_changed",this,"_color_changed"); add_child(popup); } - |