From 8bbeed4385c75f2a438a05df5aee848748b28117 Mon Sep 17 00:00:00 2001 From: vng Date: Sun, 21 Mar 2021 13:09:14 +0300 Subject: [PATCH] More clear SearchAPI initialization logic. Signed-off-by: vng --- map/framework.cpp | 5 ++--- map/search_api.hpp | 8 +++++--- search/geocoder.cpp | 5 +++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 327aac13e4..c875028d11 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -486,9 +486,8 @@ Framework::Framework(FrameworkParams const & params) RegisterAllMaps(); LOG(LDEBUG, ("Maps initialized")); - // Need to reload cities boundaries because maps in indexer were updated. - GetSearchAPI().LoadCitiesBoundaries(); - GetSearchAPI().CacheWorldLocalities(); + // Perform real initialization after World was loaded. + GetSearchAPI().InitAfterWorldLoaded(); m_routingManager.SetRouterImpl(RouterType::Vehicle); diff --git a/map/search_api.hpp b/map/search_api.hpp index 56d6fee254..61b27c3ccf 100644 --- a/map/search_api.hpp +++ b/map/search_api.hpp @@ -101,9 +101,11 @@ public: void OnViewportChanged(m2::RectD const & viewport); - void CacheWorldLocalities() { m_engine.CacheWorldLocalities(); } - - void LoadCitiesBoundaries() { m_engine.LoadCitiesBoundaries(); } + void InitAfterWorldLoaded() + { + m_engine.CacheWorldLocalities(); + m_engine.LoadCitiesBoundaries(); + } // Search everywhere. bool SearchEverywhere(search::EverywhereSearchParams const & params); diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 34ef83db37..323c751fb0 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -722,6 +722,11 @@ void Geocoder::CacheWorldLocalities() UNUSED_VALUE(m_localitiesCaches.m_states.Get(*context)); UNUSED_VALUE(m_localitiesCaches.m_citiesTownsOrVillages.Get(*context)); } + else + { + // This is strange situation, anyway. + LOG(LWARNING, ("Can't find World map file.")); + } } void Geocoder::FillLocalitiesTable(BaseContext const & ctx)