[nautilus] Centralize extra view ref and sink if required



commit 26a91c8e225f01363976485c782840135d50e6d8
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Sep 7 15:21:59 2009 +0200

    Centralize extra view ref and sink if required
    
    Doing this in only one place makes sense as its clearer.
    Previously we ref:ed one extra time for the window->view ref but left
    the floating ref to be taked when adding the widget to a parent.
    This breaks when we free the view before adding it to a parent, so
    we need to properly sink it.

 libnautilus-private/nautilus-view-factory.c |    7 ++++++-
 src/file-manager/fm-desktop-icon-view.c     |    1 -
 src/file-manager/fm-empty-view.c            |    1 -
 src/file-manager/fm-icon-view.c             |    2 --
 src/file-manager/fm-list-view.c             |    1 -
 5 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/libnautilus-private/nautilus-view-factory.c b/libnautilus-private/nautilus-view-factory.c
index 1455bab..d5476c2 100644
--- a/libnautilus-private/nautilus-view-factory.c
+++ b/libnautilus-private/nautilus-view-factory.c
@@ -60,13 +60,18 @@ nautilus_view_factory_create (const char *id,
 			      NautilusWindowSlotInfo *slot)
 {
 	const NautilusViewInfo *view_info;
+	NautilusView *view;
 
 	view_info = nautilus_view_factory_lookup (id);
 	if (view_info == NULL) {
 		return NULL;
 	}
 
-	return view_info->create (slot);
+	view = view_info->create (slot);
+	if (g_object_is_floating (view)) {
+		g_object_ref_sink (view);
+	}
+	return view;
 }
 
 gboolean
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 039f150..e95ff60 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -804,7 +804,6 @@ fm_desktop_icon_view_create (NautilusWindowSlotInfo *slot)
 	view = g_object_new (FM_TYPE_DESKTOP_ICON_VIEW,
 			     "window-slot", slot,
 			     NULL);
-	g_object_ref (view);
 	return NAUTILUS_VIEW (view);
 }
 
diff --git a/src/file-manager/fm-empty-view.c b/src/file-manager/fm-empty-view.c
index 487015a..09a996d 100644
--- a/src/file-manager/fm-empty-view.c
+++ b/src/file-manager/fm-empty-view.c
@@ -355,7 +355,6 @@ fm_empty_view_create (NautilusWindowSlotInfo *slot)
 	view = g_object_new (FM_TYPE_EMPTY_VIEW,
 			     "window-slot", slot,
 			     NULL);
-	g_object_ref (view);
 
 	return NAUTILUS_VIEW (view);
 }
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 309e5cf..09d5fe9 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -3000,7 +3000,6 @@ fm_icon_view_create (NautilusWindowSlotInfo *slot)
 			     "window-slot", slot,
 			     "compact", FALSE,
 			     NULL);
-	g_object_ref (view);
 	return NAUTILUS_VIEW (view);
 }
 
@@ -3013,7 +3012,6 @@ fm_compact_view_create (NautilusWindowSlotInfo *slot)
 			     "window-slot", slot,
 			     "compact", TRUE,
 			     NULL);
-	g_object_ref (view);
 	return NAUTILUS_VIEW (view);
 }
 
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index c82de19..aec3963 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -2890,7 +2890,6 @@ fm_list_view_create (NautilusWindowSlotInfo *slot)
 	view = g_object_new (FM_TYPE_LIST_VIEW,
 			     "window-slot", slot,
 			     NULL);
-	g_object_ref (view);
 	return NAUTILUS_VIEW (view);
 }
 



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