[gimp] app: protect GimpContext's "parent" pointer against dangling



commit ef5bd98e999e567c5b536350650e20a538d13f65
Author: Michael Natterer <mitch gimp org>
Date:   Wed Apr 25 19:20:12 2018 +0200

    app: protect GimpContext's "parent" pointer against dangling
    
    with a weak ref and call set_parent(NULL) in dispose().

 app/core/gimpcontext.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c
index 39f3d28..3f2d3cf 100644
--- a/app/core/gimpcontext.c
+++ b/app/core/gimpcontext.c
@@ -964,6 +964,8 @@ gimp_context_dispose (GObject *object)
 {
   GimpContext *context = GIMP_CONTEXT (object);
 
+  gimp_context_set_parent (context, NULL);
+
   if (context->gimp)
     {
       context->gimp->context_list = g_list_remove (context->gimp->context_list,
@@ -1479,12 +1481,18 @@ gimp_context_set_parent (GimpContext *context,
       g_signal_handlers_disconnect_by_func (context->parent,
                                             gimp_context_parent_notify,
                                             context);
+
+      g_object_remove_weak_pointer (G_OBJECT (context->parent),
+                                    (gpointer) &context->parent);
     }
 
   context->parent = parent;
 
   if (parent)
     {
+      g_object_add_weak_pointer (G_OBJECT (context->parent),
+                                 (gpointer) &context->parent);
+
       /*  copy all undefined properties from the new parent  */
       gimp_context_copy_properties (parent, context,
                                     ~context->defined_props &


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