diff --git a/app/pdb/brush-cmds.c b/app/pdb/brush-cmds.c index e87069b2d0..76094eb178 100644 --- a/app/pdb/brush-cmds.c +++ b/app/pdb/brush-cmds.c @@ -162,19 +162,22 @@ brush_get_info_invoker (GimpProcedure *procedure, { GimpTempBuf *mask = gimp_brush_get_mask (brush); GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush); - const Babl *format; + const Babl *format = NULL; - format = gimp_babl_compat_u8_mask_format ( - gimp_temp_buf_get_format (mask)); + if (brush) + format = gimp_babl_compat_u8_mask_format (gimp_temp_buf_get_format (mask)); width = gimp_brush_get_width (brush); height = gimp_brush_get_height (brush); - mask_bpp = babl_format_get_bytes_per_pixel (format); - if (pixmap) + if (format) + mask_bpp = babl_format_get_bytes_per_pixel (format); + else + mask_bpp = 0; + + if (pixmap && format) { - format = gimp_babl_compat_u8_format ( - gimp_temp_buf_get_format (pixmap)); + format = gimp_babl_compat_u8_format (gimp_temp_buf_get_format (pixmap)); color_bpp = babl_format_get_bytes_per_pixel (format); } diff --git a/libgimp/gimpbrushchooser.c b/libgimp/gimpbrushchooser.c index 4b7f00f503..0833dd614d 100644 --- a/libgimp/gimpbrushchooser.c +++ b/libgimp/gimpbrushchooser.c @@ -217,6 +217,8 @@ gimp_brush_chooser_get_brush_bitmap (GimpBrushChooser *chooser, GimpBrush *brush; g_object_get (chooser, "resource", &brush, NULL); + if (! brush) + return; if (chooser->brush == brush && chooser->width == width && diff --git a/pdb/groups/brush.pdb b/pdb/groups/brush.pdb index 22caa563e8..56f0eb3c88 100644 --- a/pdb/groups/brush.pdb +++ b/pdb/groups/brush.pdb @@ -138,19 +138,22 @@ HELP { GimpTempBuf *mask = gimp_brush_get_mask (brush); GimpTempBuf *pixmap = gimp_brush_get_pixmap (brush); - const Babl *format; + const Babl *format = NULL; - format = gimp_babl_compat_u8_mask_format ( - gimp_temp_buf_get_format (mask)); + if (brush) + format = gimp_babl_compat_u8_mask_format (gimp_temp_buf_get_format (mask)); width = gimp_brush_get_width (brush); height = gimp_brush_get_height (brush); - mask_bpp = babl_format_get_bytes_per_pixel (format); - if (pixmap) + if (format) + mask_bpp = babl_format_get_bytes_per_pixel (format); + else + mask_bpp = 0; + + if (pixmap && format) { - format = gimp_babl_compat_u8_format ( - gimp_temp_buf_get_format (pixmap)); + format = gimp_babl_compat_u8_format (gimp_temp_buf_get_format (pixmap)); color_bpp = babl_format_get_bytes_per_pixel (format); } diff --git a/plug-ins/gfig/gfig-dialog.c b/plug-ins/gfig/gfig-dialog.c index cc464745f0..5d1a248e65 100644 --- a/plug-ins/gfig/gfig-dialog.c +++ b/plug-ins/gfig/gfig-dialog.c @@ -630,7 +630,8 @@ gfig_dialog (GimpGfig *gfig) gfig_list_load_all (gfig_path); /* Setup initial brush settings */ - set_context_bdesc (gimp_context_get_brush ()); + if (gimp_context_get_brush ()) + set_context_bdesc (gimp_context_get_brush ()); gtk_widget_show (main_hbox); diff --git a/plug-ins/gfig/gfig-style.c b/plug-ins/gfig/gfig-style.c index c086bad289..6b5c4a0bb9 100644 --- a/plug-ins/gfig/gfig-style.c +++ b/plug-ins/gfig/gfig-style.c @@ -533,7 +533,8 @@ gfig_brush_changed_callback (gpointer user_data, current_style->brush = brush; /* this will soon be unneeded. How soon? */ - set_context_bdesc (brush); + if (brush) + set_context_bdesc (brush); gimp_context_set_brush (brush); gimp_context_set_brush_default_size (); @@ -660,12 +661,24 @@ gfig_read_gimp_style (Style *style, style->fill_opacity = 100.; /* Cache attributes of brush. */ - gimp_brush_get_info (style->brush, - &style->brush_width, &style->brush_height, - &dummy, &dummy); - style->brush_spacing = gimp_brush_get_spacing (style->brush); + if (style->brush) + { + gimp_brush_get_info (style->brush, + &style->brush_width, &style->brush_height, + &dummy, &dummy); + style->brush_spacing = gimp_brush_get_spacing (style->brush); - set_context_bdesc (style->brush); + set_context_bdesc (style->brush); + } + else + { + style->brush_width = 1; + style->brush_height = 1; + style->brush_spacing = 1; + + gfig_context->bdesc.width = 48; + gfig_context->bdesc.height = 48; + } } /* @@ -695,16 +708,20 @@ gfig_style_set_context_from_style (Style *style) gimp_context_set_brush_default_size (); - gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->brush_select), - GIMP_RESOURCE (style->brush)); + if (style->brush) + gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->brush_select), + GIMP_RESOURCE (style->brush)); - gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->pattern_select), - GIMP_RESOURCE (style->pattern)); + if (style->pattern) + gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->pattern_select), + GIMP_RESOURCE (style->pattern)); - gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->gradient_select), - GIMP_RESOURCE (style->gradient)); + if (style->gradient) + gimp_resource_chooser_set_resource (GIMP_RESOURCE_CHOOSER (gfig_context->gradient_select), + GIMP_RESOURCE (style->gradient)); - set_context_bdesc (style->brush); + if (style->brush) + set_context_bdesc (style->brush); if (gfig_context->debug_styles) g_printerr ("done.\n");