From 685dc5ff5b9d6ede6cfbc8598490f2ef7a97f556 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Wed, 16 Apr 2003 20:18:27 +0000 Subject: [PATCH] 147068 patch by kd-moz@tprac.de r=shliang sr=jag Remove duplicate results appearing in sidebar search --- .../search/resources/internetresults.js | 46 ++++++++++++------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/xpfe/components/search/resources/internetresults.js b/xpfe/components/search/resources/internetresults.js index a1f85e553ab6..e9c2f1383abc 100644 --- a/xpfe/components/search/resources/internetresults.js +++ b/xpfe/components/search/resources/internetresults.js @@ -33,32 +33,44 @@ function searchResultsOpenURL(event) } +// Workaround for bug 196057 (double onload event): accept only the first onload event +// ( This workaround will fix bug 147068 (duplicate search results). +// Without this fix, xpfe\components\search\src\nsInternetSearchService.cpp will +// crash when removing the same tree node twice. ) +// If bug 196057 should be fixed eventually, this workaround does no harm - +// nevertheless it should be removed then +var gbProcessOnloadEvent = true; function onLoadInternetResults() { - // clear any previous results on load - var iSearch = Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"] - .getService(Components.interfaces.nsIInternetSearchService); - iSearch.ClearResultSearchSites(); + if (gbProcessOnloadEvent) + { // forbid other onload events + gbProcessOnloadEvent = false; - // the search URI is passed in as a parameter, so get it and them root the results list - var searchURI = top._content.location.href; - if (searchURI) { - const lastSearchURIPref = "browser.search.lastMultipleSearchURI"; - var offset = searchURI.indexOf("?"); - if (offset > 0) { - nsPreferences.setUnicharPref(lastSearchURIPref, searchURI); // evil - searchURI = searchURI.substr(offset+1); - loadResultsList(searchURI); - } - else { - searchURI = nsPreferences.copyUnicharPref(lastSearchURIPref, ""); - offset = searchURI.indexOf("?"); + // clear any previous results on load + var iSearch = Components.classes["@mozilla.org/rdf/datasource;1?name=internetsearch"] + .getService(Components.interfaces.nsIInternetSearchService); + iSearch.ClearResultSearchSites(); + + // the search URI is passed in as a parameter, so get it and them root the results list + var searchURI = top._content.location.href; + if (searchURI) { + const lastSearchURIPref = "browser.search.lastMultipleSearchURI"; + var offset = searchURI.indexOf("?"); if (offset > 0) { nsPreferences.setUnicharPref(lastSearchURIPref, searchURI); // evil searchURI = searchURI.substr(offset+1); loadResultsList(searchURI); } + else { + searchURI = nsPreferences.copyUnicharPref(lastSearchURIPref, ""); + offset = searchURI.indexOf("?"); + if (offset > 0) { + nsPreferences.setUnicharPref(lastSearchURIPref, searchURI); // evil + searchURI = searchURI.substr(offset+1); + loadResultsList(searchURI); + } + } } } return true;