Fix a bug trying to select a color index < 0 when there is no color selected in the palette view.

This commit is contained in:
David Capello 2012-05-02 23:09:56 -03:00
parent b30d28e920
commit ade6b0d333
2 changed files with 5 additions and 1 deletions

View File

@ -70,6 +70,8 @@ Color Color::fromGray(int g)
// static
Color Color::fromIndex(int index)
{
assert(index >= 0 && index < Palette::MaxColors);
Color color(Color::IndexType);
color.m_value.index = index;
return color;

View File

@ -836,7 +836,9 @@ void PaletteEntryEditor::onPalChange()
{
if (!m_selfPalChange) {
PaletteView* palette_editor = app_get_colorbar()->getPaletteView();
setColor(Color::fromIndex(palette_editor->getSelectedEntry()));
int index = palette_editor->getSelectedEntry();
if (index >= 0)
setColor(Color::fromIndex(index));
// Redraw the window
invalidate();