[gnome-clocks] search-provider: be robust to the shell calling get_subresults directly
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] search-provider: be robust to the shell calling get_subresults directly
- Date: Sun, 12 Oct 2014 13:16:25 +0000 (UTC)
commit 21f3ee8fde3dceedeba3aca91fbbd4da049e7620
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Oct 12 15:15:12 2014 +0200
search-provider: be robust to the shell calling get_subresults directly
src/search-provider.vala | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/search-provider.vala b/src/search-provider.vala
index 8529cde..090d294 100644
--- a/src/search-provider.vala
+++ b/src/search-provider.vala
@@ -84,14 +84,27 @@ public class SearchProvider : Object {
return result.data;
}
- public string[] get_subsearch_result_set (string[] previous_results, string[] terms) {
- var normalized_terms = normalize_terms (terms);
-
+ public async string[] get_subsearch_result_set (string[] previous_results, string[] terms) {
var result = new GenericArray<string> ();
- foreach (var id in previous_results) {
- var location = matches.get (id);
- if (location != null && location_matches (location, normalized_terms)) {
+
+ // It looks like the shell sometimes calls get_subsearch directly
+ // without calling get_initial first... not sure whether this is a
+ // gnome-shell bug or if it is by design in some condition that
+ // eludes me. Either way, if that happens, let's just fall back to
+ // a full initial search
+ if (matches == null) {
+ yield get_initial_result_set (terms);
+ matches.foreach ((id, location) => {
result.add (id);
+ });
+ } else {
+ var normalized_terms = normalize_terms (terms);
+
+ foreach (var id in previous_results) {
+ var location = matches.get (id);
+ if (location != null && location_matches (location, normalized_terms)) {
+ result.add (id);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]