diff options
author | vng <viktor.govako@gmail.com> | 2012-06-23 05:23:12 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:40:13 +0300 |
commit | d907bcc454b0cd6a5a32a7a831cf4eaed83d934f (patch) | |
tree | 68fa675ebf474e3b4dcbc0b9e2de4ab62dc3a709 /indexer/mwm_set.cpp | |
parent | 92236836ac5f64bf43556850b599daf5d0d06d17 (diff) |
Fix bug with adding invalid mwm file to maps container in MwmSet.
Diffstat (limited to 'indexer/mwm_set.cpp')
-rw-r--r-- | indexer/mwm_set.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index e239bfed67..8d763e08a8 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -23,6 +23,12 @@ namespace }; } // unnamed namespace +MwmInfo::MwmInfo() : m_lockCount(0), m_status(STATUS_REMOVED) +{ + // Important: STATUS_REMOVED - is the default value. + // Apply STATUS_ACTIVE before adding to maps container. +} + MwmSet::MwmLock::MwmLock(MwmSet const & mwmSet, MwmId mwmId) : m_mwmSet(mwmSet), m_id(mwmId), m_pValue(mwmSet.LockValue(mwmId)) { @@ -84,9 +90,8 @@ MwmSet::MwmId MwmSet::GetFreeId() if (m_info[i].m_status == MwmInfo::STATUS_REMOVED) return i; } + m_info.push_back(MwmInfo()); - m_info.back().m_status = MwmInfo::STATUS_REMOVED; - m_info.back().m_lockCount = 0; m_name.push_back(string()); return size; } @@ -123,14 +128,18 @@ int MwmSet::Add(string const & fileName, m2::RectD & r) return -1; } + // this function can throw an exception for bad mwm file + MwmInfo info; + int const version = GetInfo(fileName, info); + + info.m_status = MwmInfo::STATUS_ACTIVE; + MwmId const id = GetFreeId(); m_name[id] = fileName; - memset(&m_info[id], 0, sizeof(MwmInfo)); - int const version = GetInfo(fileName, m_info[id]); - m_info[id].m_lockCount = 0; - m_info[id].m_status = MwmInfo::STATUS_ACTIVE; + m_info[id] = info; - r = m_info[id].m_limitRect; + r = info.m_limitRect; + ASSERT ( r.IsValid(), () ); return version; } |