diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2017-11-25 12:39:22 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-07-20 18:27:32 +0200 |
commit | 0d8083510296dd2996a60a62a00579481c9aa7fb (patch) | |
tree | 8203f205af899988869c2f048c3125ca44a60b57 | |
parent | dffa19e78aa185db3bc3068a43e0035f13a5c83e (diff) | |
download | tracker-0d8083510296dd2996a60a62a00579481c9aa7fb.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.vala | 8 |
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)] |