[polari/wip/carlosg/tracker: 3/13] lib: Add explicit method to close the tracker sparql connection



commit eb9d311d803d681beaab12ad5d8e3d29c42585dd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 24 22:51:07 2019 +0100

    lib: Add explicit method to close the tracker sparql connection
    
    One of the responsibilities of a local store is properly shutting
    down the connection on exit. Unclean shutdowns are not problematic
    per se, but will trigger additional checks on next startup.

 src/lib/polari-util.c | 15 +++++++++++++++
 src/lib/polari-util.h |  1 +
 src/main.js           |  7 +++++--
 src/polari-log-tool.c |  2 ++
 4 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/src/lib/polari-util.c b/src/lib/polari-util.c
index abf38c9..3f72a50 100644
--- a/src/lib/polari-util.c
+++ b/src/lib/polari-util.c
@@ -171,3 +171,18 @@ polari_util_get_tracker_connection (gboolean readonly,
 
   return connection;
 }
+
+/**
+ * polari_util_close_tracker_connection:
+ *
+ * Returns: (transfer none):
+ */
+void
+polari_util_close_tracker_connection (void)
+{
+  TrackerSparqlConnection *connection = NULL;
+
+  connection = polari_util_get_tracker_connection (TRUE, NULL);
+  if (connection)
+    g_object_unref (connection);
+}
diff --git a/src/lib/polari-util.h b/src/lib/polari-util.h
index 6804921..fa83be2 100644
--- a/src/lib/polari-util.h
+++ b/src/lib/polari-util.h
@@ -33,3 +33,4 @@ gboolean polari_util_match_identify_message (const char  *message,
 
 TrackerSparqlConnection *polari_util_get_tracker_connection   (gboolean   readonly,
                                                                GError   **error);
+void                     polari_util_close_tracker_connection (void);
diff --git a/src/main.js b/src/main.js
index 6c0900e..931d286 100755
--- a/src/main.js
+++ b/src/main.js
@@ -17,7 +17,7 @@ pkg.requireSymbol('GLib', '2.0', 'log_variant');
 pkg.requireSymbol('Gspell', '1', 'Entry');
 pkg.requireSymbol('Gtk', '3.0', 'ScrolledWindow.propagate_natural_width');
 
-const { GLib } = imports.gi;
+const { GLib, Polari } = imports.gi;
 
 const { Application } = imports.application;
 
@@ -58,5 +58,8 @@ function main(args) {
     let application = new Application();
     if (GLib.getenv('POLARI_PERSIST'))
         application.hold();
-    return application.run(args);
+
+    let retval = application.run(args);
+    Polari.util_close_tracker_connection ();
+    return retval;
 }
diff --git a/src/polari-log-tool.c b/src/polari-log-tool.c
index dfc9a52..ee80cb7 100644
--- a/src/polari-log-tool.c
+++ b/src/polari-log-tool.c
@@ -167,6 +167,8 @@ handle_import (int   argc,
   g_object_unref (importer);
   g_main_loop_unref (loop);
 
+  polari_util_close_tracker_connection ();
+
   return status;
 }
 


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