[gimp] app: gimp_data_duplicate() reset name, filename, writable and deletable



commit 3873aa5cac960061f905ffd6bed44b5a3c995166
Author: Michael Natterer <mitch gimp org>
Date:   Mon Feb 7 19:38:23 2011 +0100

    app: gimp_data_duplicate() reset name, filename, writable and deletable
    
    to default values on the copy, so the duplicated data behaves as
    documented, even if a subclass copied too much. Makes duplicated
    dynamics work.

 app/core/gimpdata.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/app/core/gimpdata.c b/app/core/gimpdata.c
index 81705ea..30f90cd 100644
--- a/app/core/gimpdata.c
+++ b/app/core/gimpdata.c
@@ -915,7 +915,24 @@ gimp_data_duplicate (GimpData *data)
   g_return_val_if_fail (GIMP_IS_DATA (data), NULL);
 
   if (GIMP_DATA_GET_CLASS (data)->duplicate)
-    return GIMP_DATA_GET_CLASS (data)->duplicate (data);
+    {
+      GimpData        *new     = GIMP_DATA_GET_CLASS (data)->duplicate (data);
+      GimpDataPrivate *private = GIMP_DATA_GET_PRIVATE (new);
+
+      g_object_set (new,
+                    "name",      NULL,
+                    "writable",  GIMP_DATA_GET_CLASS (new)->save != NULL,
+                    "deletable", TRUE,
+                    NULL);
+
+      if (private->filename)
+        {
+          g_free (private->filename);
+          private->filename = NULL;
+        }
+
+      return new;
+    }
 
   return NULL;
 }



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