[gimp] app: don't crash if the palette is NULL
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: don't crash if the palette is NULL
- Date: Thu, 28 Oct 2010 00:17:38 +0000 (UTC)
commit 32d5d1681bc3a5dbe23e5f34060350180e0fa766
Author: Michael Natterer <mitch gimp org>
Date: Thu Oct 28 02:15:16 2010 +0200
app: don't crash if the palette is NULL
app/widgets/gimppaletteview.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/app/widgets/gimppaletteview.c b/app/widgets/gimppaletteview.c
index cb01019..6e6d856 100644
--- a/app/widgets/gimppaletteview.c
+++ b/app/widgets/gimppaletteview.c
@@ -293,11 +293,13 @@ gimp_palette_view_focus (GtkWidget *widget,
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);
- 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);
@@ -431,22 +433,23 @@ gimp_palette_view_find_entry (GimpPaletteView *view,
gint x,
gint y)
{
+ GimpPalette *palette;
GimpViewRendererPalette *renderer;
GimpPaletteEntry *entry = NULL;
gint col, row;
+ palette = GIMP_PALETTE (GIMP_VIEW (view)->renderer->viewable);
renderer = GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (view)->renderer);
+ if (! palette)
+ return NULL;
+
col = x / renderer->cell_width;
row = y / renderer->cell_height;
if (col >= 0 && col < renderer->columns &&
row >= 0 && row < renderer->rows)
{
- GimpPalette *palette;
-
- palette = GIMP_PALETTE (GIMP_VIEW (view)->renderer->viewable);
-
entry = gimp_palette_get_entry (palette,
row * renderer->columns + col);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]