[aseprite] 193/308: Fix crash when the palette editor is slowly resized to its minimum size (fix #949)
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:10 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 3a79cf5559d648dd64c7aafd0ffe948bf546dc67
Author: David Capello <davidcapello at gmail.com>
Date: Sun Jan 31 19:57:33 2016 -0300
Fix crash when the palette editor is slowly resized to its minimum size (fix #949)
It was caused by a division by zero.
---
src/app/ui/color_sliders.cpp | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/app/ui/color_sliders.cpp b/src/app/ui/color_sliders.cpp
index 92c7992..1ccde37 100644
--- a/src/app/ui/color_sliders.cpp
+++ b/src/app/ui/color_sliders.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -46,28 +46,30 @@ namespace {
void paint(Slider* slider, Graphics* g, const gfx::Rect& rc) {
gfx::Color color = gfx::ColorNone;
- for (int x=0; x < rc.w; ++x) {
+ int w = MAX(rc.w-1, 1);
+
+ for (int x=0; x <= w; ++x) {
switch (m_channel) {
case ColorSliders::Red:
- color = gfx::rgba(255 * x / (rc.w-1), m_color.getGreen(), m_color.getBlue());
+ color = gfx::rgba(255 * x / w, m_color.getGreen(), m_color.getBlue());
break;
case ColorSliders::Green:
- color = gfx::rgba(m_color.getRed(), 255 * x / (rc.w-1), m_color.getBlue());
+ color = gfx::rgba(m_color.getRed(), 255 * x / w, m_color.getBlue());
break;
case ColorSliders::Blue:
- color = gfx::rgba(m_color.getRed(), m_color.getGreen(), 255 * x / (rc.w-1));
+ color = gfx::rgba(m_color.getRed(), m_color.getGreen(), 255 * x / w);
break;
case ColorSliders::Hue:
- color = color_utils::color_for_ui(app::Color::fromHsv(360 * x / (rc.w-1), m_color.getSaturation(), m_color.getValue()));
+ color = color_utils::color_for_ui(app::Color::fromHsv(360 * x / w, m_color.getSaturation(), m_color.getValue()));
break;
case ColorSliders::Saturation:
- color = color_utils::color_for_ui(app::Color::fromHsv(m_color.getHue(), 100 * x / (rc.w-1), m_color.getValue()));
+ color = color_utils::color_for_ui(app::Color::fromHsv(m_color.getHue(), 100 * x / w, m_color.getValue()));
break;
case ColorSliders::Value:
- color = color_utils::color_for_ui(app::Color::fromHsv(m_color.getHue(), m_color.getSaturation(), 100 * x / (rc.w-1)));
+ color = color_utils::color_for_ui(app::Color::fromHsv(m_color.getHue(), m_color.getSaturation(), 100 * x / w));
break;
case ColorSliders::Gray:
- color = color_utils::color_for_ui(app::Color::fromGray(255 * x / (rc.w-1)));
+ color = color_utils::color_for_ui(app::Color::fromGray(255 * x / w));
break;
}
g->drawVLine(color, rc.x+x, rc.y, rc.h);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list