[gtksourceview] completion: remove use of g_autoptr()



commit b10246dea4d89aa5a36b9108a15a2289a0c83671
Author: Christian Hergert <chergert redhat com>
Date:   Tue Sep 22 10:48:18 2020 -0700

    completion: remove use of g_autoptr()
    
    These were supposed to be removed when porting.

 gtksourceview/gtksourcecompletion.c        |  7 +++++--
 gtksourceview/gtksourcecompletioncontext.c | 29 +++++++++++++++++++----------
 2 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 1e1f47dd..917679aa 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -387,7 +387,7 @@ static void
 gtk_source_completion_start (GtkSourceCompletion           *self,
                              GtkSourceCompletionActivation  activation)
 {
-       g_autoptr(GtkSourceCompletionContext) context = NULL;
+       GtkSourceCompletionContext *context = NULL;
        GtkTextBuffer *buffer;
        GtkTextIter begin;
        GtkTextIter end;
@@ -400,7 +400,7 @@ gtk_source_completion_start (GtkSourceCompletion           *self,
        if (!gtk_source_completion_compute_bounds (self, &begin, &end))
        {
                if (activation == GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE)
-                       return;
+                       goto cleanup;
                begin = end;
        }
 
@@ -432,6 +432,9 @@ gtk_source_completion_start (GtkSourceCompletion           *self,
                else
                        display_hide (self->display);
        }
+
+cleanup:
+       g_clear_object (&context);
 }
 
 static void
diff --git a/gtksourceview/gtksourcecompletioncontext.c b/gtksourceview/gtksourcecompletioncontext.c
index 9a84d6c9..27e9376e 100644
--- a/gtksourceview/gtksourcecompletioncontext.c
+++ b/gtksourceview/gtksourcecompletioncontext.c
@@ -393,16 +393,13 @@ gtk_source_completion_context_get_item (GListModel *model,
                                         guint       position)
 {
        GtkSourceCompletionContext *self = (GtkSourceCompletionContext *)model;
-       g_autoptr(GtkSourceCompletionProposal) proposal = NULL;
+       GtkSourceCompletionProposal *proposal = NULL;
 
        g_assert (GTK_SOURCE_IS_COMPLETION_CONTEXT (self));
 
-       if (_gtk_source_completion_context_get_item_full (self, position, NULL, &proposal))
-       {
-               return g_steal_pointer (&proposal);
-       }
+       _gtk_source_completion_context_get_item_full (self, position, NULL, &proposal);
 
-       return NULL;
+       return g_steal_pointer (&proposal);
 }
 
 static void
@@ -660,9 +657,9 @@ gtk_source_completion_context_populate_cb (GObject      *object,
        GtkSourceCompletionProvider *provider = (GtkSourceCompletionProvider *)object;
        GtkSourceCompletionContext *self;
        CompleteTaskData *task_data;
-       g_autoptr(GListModel) results = NULL;
-       g_autoptr(GTask) task = user_data;
-       g_autoptr(GError) error = NULL;
+       GListModel *results = NULL;
+       GTask *task = user_data;
+       GError *error = NULL;
 
        g_assert (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider));
        g_assert (G_IS_ASYNC_RESULT (result));
@@ -675,16 +672,26 @@ gtk_source_completion_context_populate_cb (GObject      *object,
        g_assert (task_data != NULL);
 
        if (!(results = gtk_source_completion_provider_populate_finish (provider, result, &error)))
+       {
                gtk_source_completion_context_mark_failed (self, provider, error);
+       }
        else
+       {
                gtk_source_completion_context_set_proposals_for_provider (self, provider, results);
+       }
 
        task_data->n_active--;
 
        gtk_source_completion_context_update_empty (self);
 
        if (task_data->n_active == 0)
+       {
                g_task_return_boolean (task, TRUE);
+       }
+
+       g_clear_object (&results);
+       g_clear_object (&task);
+       g_clear_error (&error);
 }
 
 static void
@@ -722,7 +729,7 @@ _gtk_source_completion_context_complete_async (GtkSourceCompletionContext    *se
                                                GAsyncReadyCallback            callback,
                                                gpointer                       user_data)
 {
-       g_autoptr(GTask) task = NULL;
+       GTask *task = NULL;
        CompleteTaskData *task_data;
        GtkSourceBuffer *buffer;
        guint n_items;
@@ -784,6 +791,8 @@ _gtk_source_completion_context_complete_async (GtkSourceCompletionContext    *se
        }
 
        g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_BUSY]);
+
+       g_clear_object (&task);
 }
 
 /**


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