[tracker/external-crawler: 36/45] libtracker-miner: Create TrackerIndexingTree in constructed() not init()
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/external-crawler: 36/45] libtracker-miner: Create TrackerIndexingTree in constructed() not init()
- Date: Tue, 12 Aug 2014 18:56:07 +0000 (UTC)
commit 990d0a65c009d4d1c9415eb9c32eb04313c71aab
Author: Martyn Russell <martyn lanedo com>
Date: Tue Jul 1 10:50:30 2014 +0100
libtracker-miner: Create TrackerIndexingTree in constructed() not init()
We do this because the GFile which is the root for the TrackerMinerFS is a
property which is set on object construction. If we try to do this in init()
the root is unset at that point. So we wait until constructed where properties
are guaranteed to be set. We need this to give to the TrackerIndexingTree that
requires a root argument if the file system is not 'file:///' based.
src/libtracker-miner/tracker-miner-fs.c | 39 ++++++++++++++++++++++++------
1 files changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 639d519..98ae4ae 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -288,6 +288,7 @@ enum {
static void miner_fs_initable_iface_init (GInitableIface *iface);
static void fs_finalize (GObject *object);
+static void fs_constructed (GObject *object);
static void fs_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -367,6 +368,7 @@ tracker_miner_fs_class_init (TrackerMinerFSClass *klass)
TrackerMinerClass *miner_class = TRACKER_MINER_CLASS (klass);
object_class->finalize = fs_finalize;
+ object_class->constructed = fs_constructed;
object_class->set_property = fs_set_property;
object_class->get_property = fs_get_property;
@@ -675,14 +677,6 @@ miner_fs_initable_init (GInitable *initable,
G_CALLBACK (task_pool_limit_reached_notify_cb),
initable);
- /* Create root if one didn't exist */
- if (priv->root == NULL) {
- /* We default to file:/// */
- priv->root = g_file_new_for_uri ("file:///");
- }
-
- /* Create indexing tree */
- priv->indexing_tree = tracker_indexing_tree_new (priv->root);
if (!priv->indexing_tree) {
g_set_error (error,
tracker_miner_fs_error_quark (),
@@ -823,6 +817,35 @@ fs_finalize (GObject *object)
}
static void
+fs_constructed (GObject *object)
+{
+ TrackerMinerFSPrivate *priv;
+
+ /* NOTE: We have to do this in this order because initables
+ * are called _AFTER_ constructed and for subclasses that are
+ * not initables we don't have any other way than to chain
+ * constructed and root/indexing tree must exist at that
+ * point.
+ *
+ * If priv->indexing_tree is NULL after this function, the
+ * initiable functions will fail and this class will not be
+ * created anyway.
+ */
+ G_OBJECT_CLASS (tracker_miner_fs_parent_class)->constructed (object);
+
+ priv = TRACKER_MINER_FS_GET_PRIVATE (object);
+
+ /* Create root if one didn't exist */
+ if (priv->root == NULL) {
+ /* We default to file:/// */
+ priv->root = g_file_new_for_uri ("file:///");
+ }
+
+ /* Create indexing tree */
+ priv->indexing_tree = tracker_indexing_tree_new (priv->root);
+}
+
+static void
fs_set_property (GObject *object,
guint prop_id,
const GValue *value,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]