From 489927528dac3baa3ab43fe2a5d81a75bdd15384 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 21 Jun 2010 22:16:30 -0300 Subject: [PATCH] Fixed a bug calling "palette_editor" with invalid color (index out of range). --- src/widgets/colbar.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/widgets/colbar.cpp b/src/widgets/colbar.cpp index 17906768c..16d177c90 100644 --- a/src/widgets/colbar.cpp +++ b/src/widgets/colbar.cpp @@ -411,32 +411,36 @@ bool ColorBar::msg_proc(JMessage msg) } /* pick the color */ else if (m_hot != HOTCOLOR_NONE) { - switch (m_hot) { + color_t color = getHotColor(m_hot); - case HOTCOLOR_FGCOLOR: - case HOTCOLOR_BGCOLOR: { - Command* paledit_cmd = CommandsModule::instance()->get_command_by_name(CommandId::palette_editor); - Params params; - params.set("target", (m_hot == HOTCOLOR_FGCOLOR ? "foreground": "background")); - params.set("open", "true"); + // Check if the color is invalid (e.g. index out of range) + if (color_is_valid(color)) { - UIContext::instance()->execute_command(paledit_cmd, ¶ms); - break; - } + switch (m_hot) { - default: - color_t color = getHotColor(m_hot); + case HOTCOLOR_FGCOLOR: + case HOTCOLOR_BGCOLOR: { + Command* paledit_cmd = CommandsModule::instance()->get_command_by_name(CommandId::palette_editor); + Params params; + params.set("target", (m_hot == HOTCOLOR_FGCOLOR ? "foreground": "background")); + params.set("open", "true"); + + UIContext::instance()->execute_command(paledit_cmd, ¶ms); + break; + } + + default: { + color_t color = getHotColor(m_hot); - // Check if the color is invalid (e.g. index out of range) - if (color_is_valid(color)) { if (msg->mouse.left) { this->setFgColor(color); } if (msg->mouse.right) { this->setBgColor(color); } + break; } - break; + } } }