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.
This commit is contained in:
Alexander Larsson 2009-09-07 15:21:59 +02:00
parent c302620c14
commit 26a91c8e22
5 changed files with 6 additions and 6 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}