[nautilus/wip/corey/leaks-42: 2/3] toolbar: Don't add a ref to menu_item




commit 0588ce739a81d646923884b9c6b87f6d58f07747
Author: Ignacy KuchciƄski <ignacykuchcinski gmail com>
Date:   Mon Aug 22 10:36:42 2022 +0200

    toolbar: Don't add a ref to menu_item
    
    g_set_object adds a ref, so don't use it in this case

 src/nautilus-toolbar.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 5fe4e63a4..d4bec3cac 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -748,7 +748,8 @@ undo_manager_changed (NautilusToolbar *self)
     g_autofree gchar *redo_description = NULL;
     gboolean is_undo;
     g_autoptr (GMenu) updated_section = g_menu_new ();
-    g_autoptr (GMenuItem) menu_item = NULL;
+    g_autoptr (GMenuItem) undo_menu_item = NULL;
+    g_autoptr (GMenuItem) redo_menu_item = NULL;
 
     /* Look up the last action from the undo manager, and get the text that
      * describes it, e.g. "Undo Create Folder"/"Redo Create Folder"
@@ -776,8 +777,8 @@ undo_manager_changed (NautilusToolbar *self)
         g_free (undo_label);
         undo_label = g_strdup (_("_Undo"));
     }
-    g_set_object (&menu_item, g_menu_item_new (undo_label, "win.undo"));
-    g_menu_append_item (updated_section, menu_item);
+    undo_menu_item = g_menu_item_new (undo_label, "win.undo");
+    g_menu_append_item (updated_section, undo_menu_item);
     update_action (self, "undo", undo_active);
 
     if (!redo_active || redo_label == NULL)
@@ -785,8 +786,8 @@ undo_manager_changed (NautilusToolbar *self)
         g_free (redo_label);
         redo_label = g_strdup (_("_Redo"));
     }
-    g_set_object (&menu_item, g_menu_item_new (redo_label, "win.redo"));
-    g_menu_append_item (updated_section, menu_item);
+    redo_menu_item = g_menu_item_new (redo_label, "win.redo");
+    g_menu_append_item (updated_section, redo_menu_item);
     update_action (self, "redo", redo_active);
 
     nautilus_gmenu_set_from_model (G_MENU (self->undo_redo_section),


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