diff --git a/search/bookmarks/processor.cpp b/search/bookmarks/processor.cpp index 074202f0a9..058e3ca78c 100644 --- a/search/bookmarks/processor.cpp +++ b/search/bookmarks/processor.cpp @@ -271,6 +271,8 @@ void Processor::Search(Params const & params) const } } +void Processor::Finish(bool cancelled) { m_emitter.Finish(cancelled); } + uint64_t Processor::GetNumDocs(strings::UniString const & token, bool isPrefix) const { return base::asserted_cast( diff --git a/search/bookmarks/processor.hpp b/search/bookmarks/processor.hpp index 9f7ec2f202..2c5982406e 100644 --- a/search/bookmarks/processor.hpp +++ b/search/bookmarks/processor.hpp @@ -71,6 +71,8 @@ public: void Search(Params const & params) const; + void Finish(bool cancelled); + // IdfMap::Delegate overrides: uint64_t GetNumDocs(strings::UniString const & token, bool isPrefix) const override; diff --git a/search/processor.cpp b/search/processor.cpp index c0c6524a28..98ec213d81 100644 --- a/search/processor.cpp +++ b/search/processor.cpp @@ -449,19 +449,21 @@ void Processor::Search(SearchParams const & params) SetQuery(params.m_query); SetViewport(viewport); - Geocoder::Params geocoderParams; - InitGeocoder(geocoderParams, params); - InitPreRanker(geocoderParams, params); - InitRanker(geocoderParams, params); InitEmitter(params); - try + switch (params.m_mode) { - switch (params.m_mode) + case Mode::Everywhere: // fallthrough + case Mode::Viewport: // fallthrough + case Mode::Downloader: + { + Geocoder::Params geocoderParams; + InitGeocoder(geocoderParams, params); + InitPreRanker(geocoderParams, params); + InitRanker(geocoderParams, params); + + try { - case Mode::Everywhere: // fallthrough - case Mode::Viewport: // fallthrough - case Mode::Downloader: SearchCoordinates(); SearchPlusCode(); if (viewportSearch) @@ -474,18 +476,19 @@ void Processor::Search(SearchParams const & params) m_ranker.SuggestStrings(); m_geocoder.GoEverywhere(); } - break; - case Mode::Bookmarks: SearchBookmarks(params.m_bookmarksGroupId); break; - case Mode::Count: ASSERT(false, ("Invalid mode")); break; } - } - catch (CancelException const &) - { - LOG(LDEBUG, ("Search has been cancelled.")); - } + catch (CancelException const &) + { + LOG(LDEBUG, ("Search has been cancelled.")); + } - // Emit finish marker to client. - m_geocoder.Finish(IsCancelled()); + // Emit finish marker to client. + m_geocoder.Finish(IsCancelled()); + break; + } + case Mode::Bookmarks: SearchBookmarks(params.m_bookmarksGroupId); break; + case Mode::Count: ASSERT(false, ("Invalid mode")); break; + } if (!viewportSearch && !IsCancelled()) SendStatistics(params, viewport, m_emitter.GetResults()); @@ -531,12 +534,23 @@ void Processor::SearchPlusCode() m_emitter.Emit(); } -void Processor::SearchBookmarks(bookmarks::GroupId const & groupId) const +void Processor::SearchBookmarks(bookmarks::GroupId const & groupId) { bookmarks::Processor::Params params; InitParams(params); params.m_groupId = groupId; - m_bookmarksProcessor.Search(params); + + try + { + m_bookmarksProcessor.Search(params); + } + catch (CancelException const &) + { + LOG(LDEBUG, ("Bookmarks search has been cancelled.")); + } + + // Emit finish marker to client. + m_bookmarksProcessor.Finish(IsCancelled()); } void Processor::InitParams(QueryParams & params) const diff --git a/search/processor.hpp b/search/processor.hpp index 4b86e0a2f9..07965c8cfc 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -78,7 +78,7 @@ public: // Tries to parse a plus code from |m_query| and generate a (lat, lon) result. void SearchPlusCode(); - void SearchBookmarks(bookmarks::GroupId const & groupId) const; + void SearchBookmarks(bookmarks::GroupId const & groupId); void InitParams(QueryParams & params) const;