[gimp] Bug 729158 - Internal inconsistent state with gimp_image_get_selection...



commit bcce8c95ec7e5df9b38bf44d2d22a03ed2b3a208
Author: Michael Natterer <mitch gimp org>
Date:   Tue Apr 29 09:16:19 2014 +0200

    Bug 729158 - Internal inconsistent state with gimp_image_get_selection...
    
    + gimp_channel_copy
    
    Make gimp-channel-copy always return a GimpChannel, and fail the
    prodecure if the input channel is not of image size.

 app/pdb/channel-cmds.c       |   18 ++++++++++++++----
 tools/pdbgen/pdb/channel.pdb |   18 ++++++++++++++----
 2 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/app/pdb/channel-cmds.c b/app/pdb/channel-cmds.c
index 0886a44..4502531 100644
--- a/app/pdb/channel-cmds.c
+++ b/app/pdb/channel-cmds.c
@@ -146,10 +146,20 @@ channel_copy_invoker (GimpProcedure         *procedure,
 
   if (success)
     {
-      channel_copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
-                                   G_TYPE_FROM_INSTANCE (channel)));
-
-      if (! channel_copy)
+      GimpImage *image  = gimp_item_get_image (GIMP_ITEM (channel));
+      gint       width  = gimp_image_get_width  (image);
+      gint       height = gimp_image_get_height (image);
+
+      if (gimp_item_get_width  (GIMP_ITEM (channel)) == width &&
+          gimp_item_get_height (GIMP_ITEM (channel)) == height)
+        {
+          channel_copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
+                                                            GIMP_TYPE_CHANNEL));
+
+          if (! channel_copy)
+            success = FALSE;
+        }
+      else
         success = FALSE;
     }
 
diff --git a/tools/pdbgen/pdb/channel.pdb b/tools/pdbgen/pdb/channel.pdb
index a8bc178..0d0ae94 100644
--- a/tools/pdbgen/pdb/channel.pdb
+++ b/tools/pdbgen/pdb/channel.pdb
@@ -94,10 +94,20 @@ HELP
     %invoke = (
        code => <<'CODE'
 {
-  channel_copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
-                               G_TYPE_FROM_INSTANCE (channel)));
-
-  if (! channel_copy)
+  GimpImage *image  = gimp_item_get_image (GIMP_ITEM (channel));
+  gint       width  = gimp_image_get_width  (image);
+  gint       height = gimp_image_get_height (image);
+
+  if (gimp_item_get_width  (GIMP_ITEM (channel)) == width &&
+      gimp_item_get_height (GIMP_ITEM (channel)) == height)
+    {
+      channel_copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
+                                                        GIMP_TYPE_CHANNEL));
+
+      if (! channel_copy)
+        success = FALSE;
+    }
+  else
     success = FALSE;
 }
 CODE


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