From 492558a2d27270a5f491f5ad4982cc46410ce258 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 24 Feb 2014 17:24:42 +0100 Subject: [PATCH] search: survive the provider reporting the wrong number of metas If a provider crashes during GetResultMetas, or returns the wrong number of metas, report it as failing but don't cause a JS exception. https://bugzilla.gnome.org/show_bug.cgi?id=725020 --- js/ui/search.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/js/ui/search.js b/js/ui/search.js index e9ae6c822..e544497cf 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -340,12 +340,22 @@ const SearchResultsBase = new Lang.Class({ })); if (metasNeeded.length === 0) { - callback(); + callback(true); } else { this._cancellable.cancel(); this._cancellable.reset(); this.provider.getResultMetas(metasNeeded, Lang.bind(this, function(metas) { + if (metas.length == 0) { + callback(false); + return; + } + if (metas.length != metasNeeded.length) { + log('Wrong number of result metas returned by search provider'); + callback(false); + return; + } + metasNeeded.forEach(Lang.bind(this, function(resultId, i) { let meta = metas[i]; let display = this._createResultDisplay(meta); @@ -353,7 +363,7 @@ const SearchResultsBase = new Lang.Class({ display.actor.connect('key-focus-in', Lang.bind(this, this._keyFocusIn)); this._resultDisplays[resultId] = display; })); - callback(); + callback(true); }), this._cancellable); } }, @@ -370,8 +380,10 @@ const SearchResultsBase = new Lang.Class({ let results = this.provider.filterResults(providerResults, maxResults); let hasMoreResults = results.length < providerResults.length; - this._ensureResultActors(results, Lang.bind(this, function() { + this._ensureResultActors(results, Lang.bind(this, function(successful) { this._clearResultDisplay(); + if (!successful) + return; // To avoid CSS transitions causing flickering when // the first search result stays the same, we hide the