[gimp/wip/nielsdg/proc-loosen-typecheck: 30/30] gimpprocedure: Use less strict typechecking



commit 0f864045b7375abec00917971f97222c1165123d
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sun May 24 19:14:47 2020 +0200

    gimpprocedure: Use less strict typechecking
    
    When executing `GimpProcedure.run()`, we perform some type checking
    (and sometimes even do more validation) to make sure that plug-ins are
    behaving correctly.
    
    The problem with the current implementation was that a plug-in that
    accepted for example a single `GimpDrawable` as argument, then trying to
    call this with a value of `GIMP_TYPE_CHANNEL` didn't pass the
    validation, even though the latter is just a subclass of the former.
    
    For that reason, do a proper typecheck using `g_type_is_a()`.

 libgimp/gimpprocedure.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c
index be810a5785..d184e966e1 100644
--- a/libgimp/gimpprocedure.c
+++ b/libgimp/gimpprocedure.c
@@ -1804,7 +1804,7 @@ gimp_procedure_validate_args (GimpProcedure   *procedure,
       GType       arg_type  = G_VALUE_TYPE (arg);
       GType       spec_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
 
-      if (arg_type != spec_type)
+      if (! g_type_is_a (arg_type, spec_type))
         {
           if (return_vals)
             {


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