[nautilus] window: use g_clear_object



commit 1af49b5dd84e9127785f2c507940574d6f62ecbf
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Jan 7 01:33:00 2012 +0100

    window: use g_clear_object

 src/nautilus-window-manage-views.c |   28 ++++++++--------------------
 src/nautilus-window-menus.c        |    8 ++------
 2 files changed, 10 insertions(+), 26 deletions(-)
---
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 3367f9d..123d04d 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -119,9 +119,8 @@ set_displayed_location (NautilusWindowSlot *slot, GFile *location)
         
         if (recreate) {
                 /* We've changed locations, must recreate bookmark for current location. */
-		if (slot->last_location_bookmark != NULL)  {
-			g_object_unref (slot->last_location_bookmark);
-                }
+		g_clear_object (&slot->last_location_bookmark);
+
 		slot->last_location_bookmark = slot->current_location_bookmark;
 		slot->current_location_bookmark = (location == NULL) ? NULL
                         : nautilus_bookmark_new (location, NULL, NULL);
@@ -273,9 +272,8 @@ nautilus_window_update_up_button (NautilusWindow *window)
 	if (slot->location != NULL) {
 		parent = g_file_get_parent (slot->location);
 		allowed = parent != NULL;
-		if (parent != NULL) {
-			g_object_unref (parent);
-		}
+
+		g_clear_object (&parent);
 	}
 
 	action_group = nautilus_window_get_main_action_group (window);
@@ -570,9 +568,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
 		}
 	}
 
-	if (old_location) {
-		g_object_unref (old_location);
-	}
+	g_clear_object (&old_location);
 }
 
 const char *
@@ -1411,9 +1407,7 @@ update_for_new_location (NautilusWindowSlot *slot)
 		!g_file_equal (slot->location, new_location);
 		
         /* Set the new location. */
-	if (slot->location) {
-		g_object_unref (slot->location);
-	}
+	g_clear_object (&slot->location);
 	slot->location = new_location;
 
         /* Create a NautilusFile for this location, so we can catch it
@@ -1558,11 +1552,7 @@ free_location_change (NautilusWindowSlot *slot)
 
 	window = nautilus_window_slot_get_window (slot);
 
-	if (slot->pending_location) {
-		g_object_unref (slot->pending_location);
-	}
-        slot->pending_location = NULL;
-
+	g_clear_object (&slot->pending_location);
 	g_list_free_full (slot->pending_selection, g_object_unref);
 	slot->pending_selection = NULL;
 
@@ -1841,10 +1831,8 @@ nautilus_window_back_or_forward (NautilusWindow *window,
 			 distance,
 			 scroll_pos,
 			 NULL, NULL);
-		if (old_location) {
-			g_object_unref (old_location);
-		}
 
+		g_clear_object (&old_location);
 		g_free (scroll_pos);
 	}
 
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 6de4c29..5d8a18b 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -782,12 +782,8 @@ nautilus_window_update_split_view_actions_sensitivity (NautilusWindow *window)
 	gtk_action_set_sensitive (action, have_multiple_panes && !next_pane_is_in_same_location);
 
 	/* clean up */
-	if (active_pane_location) {
-		g_object_unref (active_pane_location);
-	}
-	if (next_pane_location) {
-		g_object_unref (next_pane_location);
-	}
+	g_clear_object (&active_pane_location);
+	g_clear_object (&next_pane_location);
 }
 
 static void



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