[nautilus] search-provider: initialize volume monitor lazily
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] search-provider: initialize volume monitor lazily
- Date: Sun, 24 May 2015 19:21:53 +0000 (UTC)
commit 7daf923b9d867fa96bf1f9ee6c2a71e406cb1dab
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat May 23 17:24:08 2015 -0700
search-provider: initialize volume monitor lazily
There is no need to initialize the volume monitor early, since it's
already a singleton.
src/nautilus-shell-search-provider.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
index a870be3..78cfb83 100644
--- a/src/nautilus-shell-search-provider.c
+++ b/src/nautilus-shell-search-provider.c
@@ -59,8 +59,6 @@ struct _NautilusShellSearchProvider {
PendingSearch *current_search;
GHashTable *metas_cache;
-
- GVolumeMonitor *volumes;
};
G_DEFINE_TYPE (NautilusShellSearchProvider, nautilus_shell_search_provider, G_TYPE_OBJECT)
@@ -267,8 +265,10 @@ search_add_volumes_and_bookmarks (PendingSearch *search)
GFile *location;
SearchHitCandidate *candidate;
NautilusBookmarkList *bookmarks;
+ GVolumeMonitor *volume_monitor;
bookmarks = nautilus_application_get_bookmarks (NAUTILUS_APPLICATION (g_application_get_default ()));
+ volume_monitor = g_volume_monitor_get ();
candidates = NULL;
/* first add bookmarks */
@@ -301,7 +301,7 @@ search_add_volumes_and_bookmarks (PendingSearch *search)
mounts_to_check = NULL;
/* first check all connected drives */
- drives = g_volume_monitor_get_connected_drives (search->self->volumes);
+ drives = g_volume_monitor_get_connected_drives (volume_monitor);
for (l = drives; l != NULL; l = l->next) {
drive = l->data;
volumes = g_drive_get_volumes (drive);
@@ -319,7 +319,7 @@ search_add_volumes_and_bookmarks (PendingSearch *search)
g_list_free_full (drives, g_object_unref);
/* then volumes that don't have a drive */
- volumes = g_volume_monitor_get_volumes (search->self->volumes);
+ volumes = g_volume_monitor_get_volumes (volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
volume = l->data;
drive = g_volume_get_drive (volume);
@@ -335,7 +335,7 @@ search_add_volumes_and_bookmarks (PendingSearch *search)
g_list_free_full (volumes, g_object_unref);
/* then mounts that have no volume */
- mounts = g_volume_monitor_get_mounts (search->self->volumes);
+ mounts = g_volume_monitor_get_mounts (volume_monitor);
for (l = mounts; l != NULL; l = l->next) {
mount = l->data;
@@ -384,6 +384,7 @@ search_add_volumes_and_bookmarks (PendingSearch *search)
}
}
g_list_free_full (candidates, (GDestroyNotify) search_hit_candidate_free);
+ g_object_unref (volume_monitor);
}
static void
@@ -679,8 +680,6 @@ search_provider_dispose (GObject *obj)
g_hash_table_destroy (self->metas_cache);
cancel_current_search (self);
- g_clear_object (&self->volumes);
-
G_OBJECT_CLASS (nautilus_shell_search_provider_parent_class)->dispose (obj);
}
@@ -689,7 +688,6 @@ nautilus_shell_search_provider_init (NautilusShellSearchProvider *self)
{
self->metas_cache = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) g_variant_unref);
- self->volumes = g_volume_monitor_get ();
self->skeleton = nautilus_shell_search_provider2_skeleton_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]