[gimp/metadata-browser] gfig: select the correct layer GimpImageType



commit 2160e84b63689af3b3ac0ef9be40875de11edad9
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Thu Feb 16 17:56:40 2012 +0100

    gfig: select the correct layer GimpImageType
    
    and avoid a warning in a useless (but not unreachable)
    code path
    
    and do not dereference a NULL pointer when a style name
    includes a white space (ex. "default style")

 plug-ins/gfig/gfig-dialog.c |    9 ++++++---
 plug-ins/gfig/gfig-style.c  |    6 ++----
 2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/plug-ins/gfig/gfig-dialog.c b/plug-ins/gfig/gfig-dialog.c
index 83b1374..488ab56 100644
--- a/plug-ins/gfig/gfig-dialog.c
+++ b/plug-ins/gfig/gfig-dialog.c
@@ -210,6 +210,7 @@ gfig_dialog (void)
   GtkWidget    *frame;
   gint          img_width;
   gint          img_height;
+  GimpImageType img_type;
   GtkWidget    *toggle;
   GtkWidget    *right_vbox;
   GtkWidget    *hbox;
@@ -221,6 +222,7 @@ gfig_dialog (void)
 
   img_width  = gimp_drawable_width (gfig_context->drawable_id);
   img_height = gimp_drawable_height (gfig_context->drawable_id);
+  img_type   = gimp_drawable_type_with_alpha (gfig_context->drawable_id);
 
   /*
    * See if there is a "gfig" parasite.  If so, this is a gfig layer,
@@ -249,7 +251,7 @@ gfig_dialog (void)
     {
       newlayer = gimp_layer_new (gfig_context->image_id, "GFig",
                                  img_width, img_height,
-                                 GIMP_RGBA_IMAGE, 100.0, GIMP_NORMAL_MODE);
+                                 img_type, 100.0, GIMP_NORMAL_MODE);
       gimp_drawable_fill (newlayer, GIMP_TRANSPARENT_FILL);
       gimp_image_insert_layer (gfig_context->image_id, newlayer, -1, -1);
       gfig_context->drawable_id = newlayer;
@@ -1790,8 +1792,9 @@ paint_combo_callback (GtkWidget *widget,
 
   switch (mtype)
     {
-    case PAINT_TYPE_MENU:
-      selvals.painttype = (PaintType) value;
+    case PAINT_BGS_MENU:
+      selvals.onlayerbg = (LayersBGType) value;
+      break;
 
     default:
       g_return_if_reached ();
diff --git a/plug-ins/gfig/gfig-style.c b/plug-ins/gfig/gfig-style.c
index 82c2261..0b3d81e 100644
--- a/plug-ins/gfig/gfig-style.c
+++ b/plug-ins/gfig/gfig-style.c
@@ -221,7 +221,8 @@ gfig_load_style (Style *style,
   offset = ftell (fp);
 
   get_line (load_buf2, MAX_LOAD_LINE, fp, 0);
-  if (1 != sscanf (load_buf2, "<Style %99s>", name))
+  /* nuke final > and preserve spaces in name */
+  if (1 != sscanf (load_buf2, "<Style %99[^>]>", name))
     {
       /* no style data, copy default style and fail silently */
       gfig_style_copy (style, &gfig_context->default_style, "default style");
@@ -232,9 +233,6 @@ gfig_load_style (Style *style,
   if (gfig_context->debug_styles)
     g_printerr ("Loading style '%s' -- ", name);
 
-  /* nuke final > in name */
-  *strrchr (name, '>') = '\0';
-
   style->name = g_strdup (name);
 
   while (TRUE)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]