[gnome-software] update dialog: Use a weak ref for the back button focus widget



commit 15454829a55814bbe9c2bfae3a6dc8d108cfaf04
Author: Kalev Lember <kalevlember gmail com>
Date:   Fri Feb 27 12:20:55 2015 +0100

    update dialog: Use a weak ref for the back button focus widget
    
    Apply a similar fix as in the previous commit to the update dialog as
    well.

 src/gs-shell.c         |    6 +++---
 src/gs-update-dialog.c |   12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index f1185d8..f04812d 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -259,9 +259,9 @@ save_back_entry (GsShell *shell)
 static void
 free_back_entry (BackEntry *entry)
 {
-       if (entry->focus)
-               g_object_remove_weak_pointer(G_OBJECT (entry->focus),
-                                            (gpointer *) &entry->focus);
+       if (entry->focus != NULL)
+               g_object_remove_weak_pointer (G_OBJECT (entry->focus),
+                                             (gpointer *) &entry->focus);
        g_clear_object (&entry->category);
        g_clear_object (&entry->app);
        g_free (entry);
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index cef3bc7..ab6f08f 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -62,16 +62,15 @@ save_back_entry (GsUpdateDialog *dialog)
 {
        GsUpdateDialogPrivate *priv = gs_update_dialog_get_instance_private (dialog);
        BackEntry *entry;
-       GtkWidget *focus;
 
        entry = g_slice_new0 (BackEntry);
        entry->stack_page = g_strdup (gtk_stack_get_visible_child_name (GTK_STACK (priv->stack)));
        entry->title = g_strdup (gtk_window_get_title (GTK_WINDOW (dialog)));
-       entry->focus = g_object_ref (gtk_window_get_focus (GTK_WINDOW (dialog)));
 
-       focus = gtk_window_get_focus (GTK_WINDOW (dialog));
-       if (focus != NULL)
-               entry->focus = g_object_ref (focus);
+       entry->focus = gtk_window_get_focus (GTK_WINDOW (dialog));
+       if (entry->focus != NULL)
+               g_object_add_weak_pointer (G_OBJECT (entry->focus),
+                                          (gpointer *) &entry->focus);
 
        g_queue_push_head (priv->back_entry_stack, entry);
 }
@@ -80,7 +79,8 @@ static void
 back_entry_free (BackEntry *entry)
 {
        if (entry->focus != NULL)
-               g_object_unref (entry->focus);
+               g_object_remove_weak_pointer (G_OBJECT (entry->focus),
+                                             (gpointer *) &entry->focus);
        g_free (entry->stack_page);
        g_free (entry->title);
        g_slice_free (BackEntry, entry);


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