summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-11-25 12:39:22 +0100
committerSam Thursfield <sam@afuera.me.uk>2018-07-16 21:12:04 +0200
commit680fd0de3983da4101af18c1b0eb797fa9621614 (patch)
tree40c4e71020a90eae708e340ed67270037e2c0070
parent7002be48b01e22f7e22cd221536b909c94c01f36 (diff)
downloadtracker-680fd0de3983da4101af18c1b0eb797fa9621614.tar.gz
tracker-store: Do immediate GraphUpdated emission checks on commit hook
Triggering those on insert/delete callbacks isn't right for two reasons: there could still be a rollback of the just notified data, and it's done from the wrong thread (the one performing updates instead of the main thread). To fix the first, only call this from the commit hook, we can only notify of data that was successfully stored. To fix the second, do the call on an idle that will ensure the main thread running the main loop and doing the DBus dispatching is the one handling the actual emission. At the moment the commit hook is actually executed on that same thread, but that won't stay as-is.
-rw-r--r--src/tracker-store/tracker-resources.vala8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/tracker-store/tracker-resources.vala b/src/tracker-store/tracker-resources.vala
index 9b6069b6b..0635b4f23 100644
--- a/src/tracker-store/tracker-resources.vala
+++ b/src/tracker-store/tracker-resources.vala
@@ -275,6 +275,7 @@ public class Tracker.Resources : Object {
void on_statements_committed () {
Tracker.Events.transact ();
Tracker.Writeback.transact ();
+ check_graph_updated_signal ();
if (signal_timeout == 0) {
signal_timeout = Timeout.add (config.graphupdated_delay, on_emit_signals);
@@ -298,20 +299,21 @@ public class Tracker.Resources : Object {
}
// immediately emit signals for already committed transaction
- on_emit_signals ();
+ Idle.add (() => {
+ on_emit_signals ();
+ return false;
+ });
}
}
void on_statement_inserted (int graph_id, string? graph, int subject_id, string subject, int pred_id, int object_id, string? object, PtrArray rdf_types) {
Tracker.Events.add_insert (graph_id, subject_id, subject, pred_id, object_id, object, rdf_types);
Tracker.Writeback.check (graph_id, graph, subject_id, subject, pred_id, object_id, object, rdf_types);
- check_graph_updated_signal ();
}
void on_statement_deleted (int graph_id, string? graph, int subject_id, string subject, int pred_id, int object_id, string? object, PtrArray rdf_types) {
Tracker.Events.add_delete (graph_id, subject_id, subject, pred_id, object_id, object, rdf_types);
Tracker.Writeback.check (graph_id, graph, subject_id, subject, pred_id, object_id, object, rdf_types);
- check_graph_updated_signal ();
}
[DBus (visible = false)]