Commit 32d5d168 authored by Michael Natterer's avatar Michael Natterer 😴

app: don't crash if the palette is NULL

parent 9dee789c
...@@ -293,11 +293,13 @@ gimp_palette_view_focus (GtkWidget *widget, ...@@ -293,11 +293,13 @@ gimp_palette_view_focus (GtkWidget *widget,
palette = GIMP_PALETTE (GIMP_VIEW (view)->renderer->viewable); palette = GIMP_PALETTE (GIMP_VIEW (view)->renderer->viewable);
if (gtk_widget_get_can_focus (widget) && ! gtk_widget_has_focus (widget)) if (gtk_widget_get_can_focus (widget) &&
! gtk_widget_has_focus (widget))
{ {
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
if (! view->selected && gimp_palette_get_n_colors (palette) > 0) if (! view->selected &&
palette && gimp_palette_get_n_colors (palette) > 0)
{ {
GimpPaletteEntry *entry = gimp_palette_get_entry (palette, 0); GimpPaletteEntry *entry = gimp_palette_get_entry (palette, 0);
...@@ -431,22 +433,23 @@ gimp_palette_view_find_entry (GimpPaletteView *view, ...@@ -431,22 +433,23 @@ gimp_palette_view_find_entry (GimpPaletteView *view,
gint x, gint x,
gint y) gint y)
{ {
GimpPalette *palette;
GimpViewRendererPalette *renderer; GimpViewRendererPalette *renderer;
GimpPaletteEntry *entry = NULL; GimpPaletteEntry *entry = NULL;
gint col, row; gint col, row;
palette = GIMP_PALETTE (GIMP_VIEW (view)->renderer->viewable);
renderer = GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (view)->renderer); renderer = GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (view)->renderer);
if (! palette)
return NULL;
col = x / renderer->cell_width; col = x / renderer->cell_width;
row = y / renderer->cell_height; row = y / renderer->cell_height;
if (col >= 0 && col < renderer->columns && if (col >= 0 && col < renderer->columns &&
row >= 0 && row < renderer->rows) row >= 0 && row < renderer->rows)
{ {
GimpPalette *palette;
palette = GIMP_PALETTE (GIMP_VIEW (view)->renderer->viewable);
entry = gimp_palette_get_entry (palette, entry = gimp_palette_get_entry (palette,
row * renderer->columns + col); row * renderer->columns + col);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment