diff --git a/routing/routing_mapping.cpp b/routing/routing_mapping.cpp index a0a786a95b..cf2e6a1447 100644 --- a/routing/routing_mapping.cpp +++ b/routing/routing_mapping.cpp @@ -55,6 +55,9 @@ RoutingMapping::RoutingMapping(string const & countryFile, MwmSet * pIndex) m_error(IRouter::ResultCode::RouteFileNotExist), m_pIndex(pIndex) { + if (m_pIndex == 0) + return; + m_handle = pIndex->GetMwmHandleByCountryFile(CountryFile(countryFile)); if (!m_handle.IsAlive()) return; @@ -80,7 +83,7 @@ RoutingMapping::RoutingMapping(string const & countryFile, MwmSet * pIndex) m_error = IRouter::ResultCode::NoError; } -void RoutingMapping::LoadFileIfNeed() +void RoutingMapping::LoadFileIfNeeded() { if (!m_handle.IsAlive() && m_mwmId.IsAlive() && m_pIndex) m_handle = m_pIndex->GetMwmHandleById(m_mwmId); @@ -102,7 +105,7 @@ RoutingMapping::~RoutingMapping() void RoutingMapping::Map() { - LoadFileIfNeed(); + LoadFileIfNeeded(); ++m_mapCounter; if (!m_segMapping.IsMapped()) { @@ -123,7 +126,7 @@ void RoutingMapping::LoadFacade() { if (!m_facadeCounter) { - LoadFileIfNeed(); + LoadFileIfNeeded(); m_dataFacade.Load(m_container); } ++m_facadeCounter; @@ -144,7 +147,7 @@ void RoutingMapping::LoadCrossContext() if (m_crossContextLoaded) return; - LoadFileIfNeed(); + LoadFileIfNeeded(); if (m_container.IsExist(ROUTING_CROSS_CONTEXT_TAG)) { diff --git a/routing/routing_mapping.hpp b/routing/routing_mapping.hpp index 7e87b1fa0c..844a6c818b 100644 --- a/routing/routing_mapping.hpp +++ b/routing/routing_mapping.hpp @@ -25,7 +25,7 @@ struct RoutingMapping /// Default constructor to create invalid instance for existing client code. /// @postcondition IsValid() == false. - RoutingMapping() = default; + RoutingMapping() : m_pIndex(nullptr) {} /// @param countryFile Country file name without extension. RoutingMapping(string const & countryFile, MwmSet * pIndex); ~RoutingMapping(); @@ -56,7 +56,7 @@ struct RoutingMapping void FreeFileIfPossible(); private: - void LoadFileIfNeed(); + void LoadFileIfNeeded(); size_t m_mapCounter; size_t m_facadeCounter; @@ -65,6 +65,7 @@ private: FilesMappingContainer m_container; IRouter::ResultCode m_error; MwmSet::MwmHandle m_handle; + // We save a mwmId for possibility to unlock a mwm file by rewriting m_handle. Index::MwmId m_mwmId; MwmSet * m_pIndex; };