[gimp] libgimpconfig: fix gimp_config_param_spec_duplicate() for objects and…



commit e7a7edd29c06c4150abbabbd4f601e8db3d49705
Author: Jehan <jehan girinstud io>
Date:   Fri Feb 11 17:31:30 2022 +0100

    libgimpconfig: fix gimp_config_param_spec_duplicate() for objects and…
    
    … object arrays.
    
    We were not supporting duplicating object pspec for no good reason. Well
    maybe the reason was that libgimpconfig does not see these types which
    are in libgimp. But then the trick is to compare by name.
    
    As for object array, they are present as subtypes of GimpArray specs.
    Yet most GimpParamSpec*Array-s are subclass of GimpParamSpecArray but
    GimpParamSpecObjectArray are their own GParamSpecBoxed subclass (same as
    the Gimp*Array-s are just typedef-s of GimpArray but GimpObjectArray is
    its own boxed type).
    So I had to move the object array test as its own case to fix support.
    
    Finally do not ignore anymore any type in gimp_config_class_init(). When
    we create a GimpConfig, we want to know when a type is not implemented
    as parameter (and if it's a well known type, we need to implement it).

 libgimpconfig/gimpconfig-params.c   | 29 +++++++++++++++++++----------
 libgimpconfig/gimpconfig-register.c |  6 +-----
 2 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/libgimpconfig/gimpconfig-params.c b/libgimpconfig/gimpconfig-params.c
index 7f87ea0285..116e650fc5 100644
--- a/libgimpconfig/gimpconfig-params.c
+++ b/libgimpconfig/gimpconfig-params.c
@@ -333,20 +333,29 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
           copy = gimp_param_spec_rgb_array (name, nick, blurb,
                                             flags);
         }
-      else if (GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (pspec))
-        {
-          GimpParamSpecObjectArray *spec = GIMP_PARAM_SPEC_OBJECT_ARRAY (pspec);
+    }
+  else if (GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (pspec))
+    {
+      GimpParamSpecObjectArray *spec = GIMP_PARAM_SPEC_OBJECT_ARRAY (pspec);
 
-          copy = gimp_param_spec_object_array (name, nick, blurb,
-                                               spec->object_type,
-                                               flags);
-        }
+      copy = gimp_param_spec_object_array (name, nick, blurb,
+                                           spec->object_type,
+                                           flags);
     }
   else if (G_IS_PARAM_SPEC_OBJECT (pspec))
     {
-      GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
-
-      if (value_type == G_TYPE_FILE)
+      GType        value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
+      const gchar *type_name  = g_type_name (value_type);
+
+      if (value_type == G_TYPE_FILE                   ||
+          /* These types are not visibile in libgimpconfig so we compare
+           * with type names instead.
+           */
+          g_strcmp0 (type_name, "GimpImage")     == 0 ||
+          g_strcmp0 (type_name, "GimpDrawable")  == 0 ||
+          g_strcmp0 (type_name, "GimpLayer")     == 0 ||
+          g_strcmp0 (type_name, "GimpSelection") == 0 ||
+          g_strcmp0 (type_name, "GimpVectors")   == 0)
         {
           copy = g_param_spec_object (name, nick, blurb,
                                       value_type,
diff --git a/libgimpconfig/gimpconfig-register.c b/libgimpconfig/gimpconfig-register.c
index 214e91da2e..0322e52cc4 100644
--- a/libgimpconfig/gimpconfig-register.c
+++ b/libgimpconfig/gimpconfig-register.c
@@ -141,12 +141,8 @@ gimp_config_class_init (GObjectClass  *klass,
         {
           g_object_class_install_property (klass, i + 1, copy);
         }
-      else if (! G_IS_PARAM_SPEC_OBJECT (pspec)  &&
-               ! G_IS_PARAM_SPEC_POINTER (pspec) &&
-               ! GIMP_IS_PARAM_SPEC_OBJECT_ARRAY (pspec))
+      else
         {
-          /*  silently ignore object properties  */
-
           g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC,
                      g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name);
         }


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