diff --git a/map/framework.cpp b/map/framework.cpp index e2401da891..0bc20b3c52 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -356,6 +356,7 @@ void Framework::Migrate(bool keepDownloaded) m_searchEngine.reset(); m_infoGetter.reset(); m_taxiEngine.reset(); + m_cityFinder.reset(); TCountriesVec existedCountries; GetStorage().DeleteAllLocalMaps(&existedCountries); DeregisterAllMaps(); @@ -363,8 +364,9 @@ void Framework::Migrate(bool keepDownloaded) GetStorage().Migrate(keepDownloaded ? existedCountries : TCountriesVec()); InitCountryInfoGetter(); InitSearchEngine(); - RegisterAllMaps(); + InitCityFinder(); InitTaxiEngine(); + RegisterAllMaps(); m_trafficManager.SetCurrentDataVersion(GetStorage().GetCurrentDataVersion()); if (m_drapeEngine && m_isRenderingEnabled) @@ -430,14 +432,19 @@ Framework::Framework(FrameworkParams const & params) m_displayedCategories = make_unique(GetDefaultCategories()); - // To avoid possible races - init country info getter once in constructor. + // To avoid possible races - init country info getter in constructor. InitCountryInfoGetter(); LOG(LDEBUG, ("Country info getter initialized")); - // To avoid possible races - init search engine once in constructor. + // To avoid possible races - init search engine in constructor. InitSearchEngine(); LOG(LDEBUG, ("Search engine initialized")); + InitCityFinder(); + InitTaxiEngine(); + + // All members which re-initialize in Migrate() method should be initialized before RegisterAllMaps(). + // Migrate() can be called from RegisterAllMaps(). RegisterAllMaps(); LOG(LDEBUG, ("Maps initialized")); @@ -472,13 +479,10 @@ Framework::Framework(FrameworkParams const & params) m_trafficManager.SetCurrentDataVersion(m_storage.GetCurrentDataVersion()); - m_cityFinder = make_unique(m_model.GetIndex()); - m_adsEngine = make_unique(); InitTransliteration(); LOG(LDEBUG, ("Transliterators initialized")); - InitTaxiEngine(); } Framework::~Framework() @@ -3304,6 +3308,13 @@ void Framework::RegisterCountryFilesOnRoute(std::shared_ptr [&ptr](platform::CountryFile const & file) { ptr->RegisterFile(file); }); } +void Framework::InitCityFinder() +{ + ASSERT(!m_cityFinder, ()); + + m_cityFinder = make_unique(m_model.GetIndex()); +} + void Framework::InitTaxiEngine() { ASSERT(!m_taxiEngine, ()); diff --git a/map/framework.hpp b/map/framework.hpp index 1a43dfbe21..23048ff924 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -840,5 +840,6 @@ private: // taxi::Engine and, therefore, destroyed after taxi::Engine. unique_ptr m_taxiEngine; + void InitCityFinder(); void InitTaxiEngine(); };