[tracker/gtk3: 6/7] tracker-needle: check cancellable after all yielded operations
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/gtk3: 6/7] tracker-needle: check cancellable after all yielded operations
- Date: Thu, 5 May 2011 12:48:34 +0000 (UTC)
commit a98dd04d2127e2c19b2437301b2948f1f2b75a0c
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu May 5 14:26:44 2011 +0200
tracker-needle: check cancellable after all yielded operations
This avoids corruptions in the model if the cancellable is cancelled
in the right moment, this could be triggered often by switching views.
src/tracker-needle/tracker-result-store.vala | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/tracker-needle/tracker-result-store.vala b/src/tracker-needle/tracker-result-store.vala
index c61316a..480bba3 100644
--- a/src/tracker-needle/tracker-result-store.vala
+++ b/src/tracker-needle/tracker-result-store.vala
@@ -92,6 +92,8 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
cursor = yield query.perform_async (op.node.query.type, op.node.query.match, op.node.query.args, cancellable);
+ cancellable.set_error_if_cancelled ();
+
for (i = op.offset; i < op.offset + 100; i++) {
ResultNode *result;
TreeIter iter;
@@ -133,7 +135,9 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
running_operations.remove (op);
} catch (GLib.IOError ie) {
- warning ("Could not load items: %s\n", ie.message);
+ if (!cancellable.is_cancelled ()) {
+ warning ("Could not load items: %s\n", ie.message);
+ }
return;
}
@@ -198,8 +202,11 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
query.criteria = _search_term;
count = yield query.get_count_async (query_data.type, query_data.match, cancellable);
+ cancellable.set_error_if_cancelled ();
} catch (GLib.IOError ie) {
- warning ("Could not get count: %s\n", ie.message);
+ if (!cancellable.is_cancelled ()) {
+ warning ("Could not get count: %s\n", ie.message);
+ }
return;
}
@@ -297,16 +304,11 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
set {
int i;
+ cancel_search ();
_search_term = value;
- if (cancellable != null) {
- cancellable.cancel ();
- cancellable = null;
- }
-
cancellable = new Cancellable ();
- clear_results ();
this.active = true;
categories = new GenericArray<CategoryNode> ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]