[gimp] app: make gimp_context_parent_notify() more robust



commit 701bc8f79b1d769f3fe03a8e52c28adfc86a264f
Author: Michael Natterer <mitch gimp org>
Date:   Mon Nov 9 01:38:37 2015 +0100

    app: make gimp_context_parent_notify() more robust
    
    Ignore notifications on properties that are not "context properties",
    which is for example the parent context's "gimp" property.
    
    A notification on "gimp" is recieved when creating the child context
    before the parent context is fully constructed, for example in the
    parent's constructed() implementation.

 app/core/gimpcontext.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c
index 0217117..daca6e6 100644
--- a/app/core/gimpcontext.c
+++ b/app/core/gimpcontext.c
@@ -1484,11 +1484,20 @@ gimp_context_parent_notify (GimpContext *parent,
                             GParamSpec  *pspec,
                             GimpContext *context)
 {
-  /*  copy from parent if the changed property is undefined  */
-  if (pspec->owner_type == GIMP_TYPE_CONTEXT &&
-      ! ((1 << pspec->param_id) & context->defined_props))
+  if (pspec->owner_type == GIMP_TYPE_CONTEXT)
     {
-      gimp_context_copy_property (parent, context, pspec->param_id);
+      GimpContextPropType prop = pspec->param_id;
+
+      /*  copy from parent if the changed property is undefined;
+       *  ignore properties that are not context properties, for
+       *  example notifications on the context's "gimp" property
+       */
+      if ((prop >= GIMP_CONTEXT_PROP_FIRST) &&
+          (prop <= GIMP_CONTEXT_PROP_LAST)  &&
+          ! ((1 << prop) & context->defined_props))
+        {
+          gimp_context_copy_property (parent, context, prop);
+        }
     }
 }
 


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