[gtksourceview/wip/various-stuff: 3/6] Revert "Prevent construction of completion after dispose has run"



commit 58f500ccd3828406d40035da358995e833fd3ebc
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jan 25 13:23:01 2014 +0100

    Revert "Prevent construction of completion after dispose has run"
    
    This reverts commit 89382601e772c0504ae7e5f709399f4dd3b0d291.
    
    It was used in get_completion() to prevent the creation of
    GtkSourceCompletion if dispose() has already run. But if
    get_completion() is called in such a (rare) situation, it means that
    GtkSourceView is still alive, and that dispose() will anyway be run a
    second time, where g_clear_object() will clear the completion object a
    second time if needed.
    
    There was before a reference cycle between the view and completion, now
    it is not the case anymore. This was maybe the root of the problem.
    
    I've tested this commit with the following program, and everything is
    fine, the completion is created and freed two times.
    
    gint
    main (gint argc, gchar *argv[])
    {
            GtkSourceView *view;
    
            gtk_init (&argc, &argv);
    
            view = GTK_SOURCE_VIEW (gtk_source_view_new ());
            g_object_ref_sink (view);
    
            gtk_source_view_get_completion (view);
    
            g_message ("main: run dispose on view");
            g_object_run_dispose (G_OBJECT (view));
    
            gtk_source_view_get_completion (view);
            g_message ("main: unref view");
            g_object_unref (view);
    
            return 0;
    }

 gtksourceview/gtksourceview.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index b3ba091..72b78d3 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -163,7 +163,6 @@ struct _GtkSourceViewPrivate
        guint            show_right_margin  : 1;
        guint            style_scheme_applied : 1;
        guint            current_line_color_set : 1;
-       guint            dispose_has_run : 1;
 };
 
 typedef struct _MarkCategory MarkCategory;
@@ -986,8 +985,6 @@ gtk_source_view_dispose (GObject *object)
        g_clear_object (&view->priv->left_gutter);
        g_clear_object (&view->priv->right_gutter);
 
-       view->priv->dispose_has_run = 1;
-
        G_OBJECT_CLASS (gtk_source_view_parent_class)->dispose (object);
 }
 
@@ -4193,7 +4190,7 @@ gtk_source_view_get_completion (GtkSourceView *view)
 {
        g_return_val_if_fail (GTK_SOURCE_IS_VIEW (view), NULL);
 
-       if (view->priv->completion == NULL && !view->priv->dispose_has_run)
+       if (view->priv->completion == NULL)
        {
                view->priv->completion = gtk_source_completion_new (view);
        }


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