From 9208473e59d800a3bab83ad831d4b72b8d25503b Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 11 Sep 2014 17:51:12 -0600 Subject: [PATCH] search: Be a bit more careful in _doSearch about timeouts --- js/ui/search.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/ui/search.js b/js/ui/search.js index 5798a4e91..f4898df3b 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -470,7 +470,15 @@ const SearchResults = new Lang.Class({ this._updateSearchProgress(); + if (this._searchTimeoutId > 0) { + GLib.source_remove(this._searchTimeoutId); + this._searchTimeoutId = 0; + } + }, + + _onSearchTimeout: function() { this._searchTimeoutId = 0; + this._doSearch(); return GLib.SOURCE_REMOVE; }, @@ -502,7 +510,7 @@ const SearchResults = new Lang.Class({ this._updateSearchProgress(); if (this._searchTimeoutId == 0) - this._searchTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, Lang.bind(this, this._doSearch)); + this._searchTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, Lang.bind(this, this._onSearchTimeout)); }, _onPan: function(action) {