[tracker/wip/carlosg/init-vtab-on-writable-iface: 1/2] libtracker-data: Avoid replacing TrackerOntology mid-initialization



commit e8282c8d9cfbc959b4ad89051f7a4217df13659f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu May 2 14:22:48 2019 +0200

    libtracker-data: Avoid replacing TrackerOntology mid-initialization
    
    This is given as user data to the TrackerDBManager and underlying ifaces
    for the "tracker_triples" virtual table, so must remain stable along its
    lifetime.
    
    The only offender here are the paths that load the ontology from the
    cache GVDB file, make tracker_ontologies_load_gvdb() take a
    TrackerOntologies to load the file into, instead of having it return
    a new one.

 src/libtracker-data/tracker-data-manager.c |  9 +--------
 src/libtracker-data/tracker-ontologies.c   | 21 ++++++++++-----------
 src/libtracker-data/tracker-ontologies.h   |  3 ++-
 3 files changed, 13 insertions(+), 20 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index bf095158e..b80cf8535 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -3954,7 +3954,6 @@ static void
 load_ontologies_gvdb (TrackerDataManager  *manager,
                       GError             **error)
 {
-       TrackerOntologies *ontologies;
        gchar *filename;
        GFile *child;
 
@@ -3962,13 +3961,7 @@ load_ontologies_gvdb (TrackerDataManager  *manager,
        filename = g_file_get_path (child);
        g_object_unref (child);
 
-       ontologies = tracker_ontologies_load_gvdb (filename, error);
-
-       if (ontologies != NULL) {
-               g_object_unref (manager->ontologies);
-               manager->ontologies = ontologies;
-       }
-
+       tracker_ontologies_load_gvdb (manager->ontologies, filename, error);
        g_free (filename);
 }
 
diff --git a/src/libtracker-data/tracker-ontologies.c b/src/libtracker-data/tracker-ontologies.c
index b8cbd90da..fc058b23a 100644
--- a/src/libtracker-data/tracker-ontologies.c
+++ b/src/libtracker-data/tracker-ontologies.c
@@ -613,26 +613,25 @@ tracker_ontologies_write_gvdb (TrackerOntologies  *ontologies,
        return retval;
 }
 
-TrackerOntologies *
-tracker_ontologies_load_gvdb (const gchar  *filename,
-                              GError      **error)
+gboolean
+tracker_ontologies_load_gvdb (TrackerOntologies  *ontologies,
+                             const gchar        *filename,
+                              GError            **error)
 {
-       TrackerOntologies *ontologies;
        TrackerOntologiesPrivate *priv;
+       GvdbTable *gvdb_table;
 
-       ontologies = tracker_ontologies_new ();
        priv = tracker_ontologies_get_instance_private (ontologies);
 
-       priv->gvdb_table = gvdb_table_new (filename, TRUE, error);
-       if (!priv->gvdb_table) {
-               g_object_unref (ontologies);
-               return NULL;
-       }
+       gvdb_table = gvdb_table_new (filename, TRUE, error);
+       if (!gvdb_table)
+               return FALSE;
 
+       priv->gvdb_table = gvdb_table;
        priv->gvdb_namespaces_table = gvdb_table_get_table (priv->gvdb_table, "namespaces");
        priv->gvdb_classes_table = gvdb_table_get_table (priv->gvdb_table, "classes");
        priv->gvdb_properties_table = gvdb_table_get_table (priv->gvdb_table, "properties");
-       return ontologies;
+       return TRUE;
 }
 
 GVariant *
diff --git a/src/libtracker-data/tracker-ontologies.h b/src/libtracker-data/tracker-ontologies.h
index c8206969c..36857df8a 100644
--- a/src/libtracker-data/tracker-ontologies.h
+++ b/src/libtracker-data/tracker-ontologies.h
@@ -93,7 +93,8 @@ void               tracker_ontologies_add_id_uri_pair      (TrackerOntologies *o
 gboolean           tracker_ontologies_write_gvdb           (TrackerOntologies  *ontologies,
                                                             const gchar        *filename,
                                                             GError            **error);
-TrackerOntologies *tracker_ontologies_load_gvdb            (const gchar        *filename,
+gboolean           tracker_ontologies_load_gvdb            (TrackerOntologies  *ontologies,
+                                                            const gchar        *filename,
                                                             GError            **error);
 GVariant *         tracker_ontologies_get_namespace_value_gvdb  (TrackerOntologies *ontologies,
                                                                  const gchar       *uri,


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