diff options
author | Yuri Gorshenin <y@maps.me> | 2016-06-02 15:55:13 +0300 |
---|---|---|
committer | Yuri Gorshenin <y@maps.me> | 2016-06-03 00:29:29 +0300 |
commit | 573021d80952bb9b82af4bac6b03622c7231b936 (patch) | |
tree | 01b19e942d4140fc537fc70771574cba62d2905d /indexer/index.cpp | |
parent | 3dff889eb4e1aa49bfd8f7226b7ec80499a33a8e (diff) |
[index] Fixed massive descriptors leaks.
Diffstat (limited to 'indexer/index.cpp')
-rw-r--r-- | indexer/index.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/indexer/index.cpp b/indexer/index.cpp index 592e8d6cdb..516e460196 100644 --- a/indexer/index.cpp +++ b/indexer/index.cpp @@ -17,27 +17,17 @@ using platform::LocalCountryFile; ////////////////////////////////////////////////////////////////////////////////// MwmValue::MwmValue(LocalCountryFile const & localFile) - : m_cont(platform::GetCountryReader(localFile, MapOptions::Map)), - m_file(localFile), - m_table(0) + : m_cont(platform::GetCountryReader(localFile, MapOptions::Map)), m_file(localFile) { m_factory.Load(m_cont); -} -void MwmValue::SetTable(MwmInfoEx & info) -{ auto const version = GetHeader().GetFormat(); if (version < version::Format::v5) - return; - - if (!info.m_table) - { - if (version == version::Format::v5) - info.m_table = feature::FeaturesOffsetsTable::CreateIfNotExistsAndLoad(m_file, m_cont); - else - info.m_table = feature::FeaturesOffsetsTable::Load(m_cont); - } - m_table = info.m_table.get(); + ; + else if (version == version::Format::v5) + m_table = feature::FeaturesOffsetsTable::CreateIfNotExistsAndLoad(m_file, m_cont); + else + m_table = feature::FeaturesOffsetsTable::Load(m_cont); } ////////////////////////////////////////////////////////////////////////////////// @@ -52,7 +42,7 @@ unique_ptr<MwmInfo> Index::CreateInfo(platform::LocalCountryFile const & localFi if (!h.IsMWMSuitable()) return nullptr; - unique_ptr<MwmInfoEx> info(new MwmInfoEx()); + auto info = make_unique<MwmInfo>(); info->m_limitRect = h.GetBounds(); pair<int, int> const scaleR = h.GetScaleRange(); @@ -60,7 +50,7 @@ unique_ptr<MwmInfo> Index::CreateInfo(platform::LocalCountryFile const & localFi info->m_maxScale = static_cast<uint8_t>(scaleR.second); info->m_version = value.GetMwmVersion(); - return unique_ptr<MwmInfo>(move(info)); + return info; } unique_ptr<MwmSet::MwmValueBase> Index::CreateValue(MwmInfo & info) const @@ -68,7 +58,6 @@ unique_ptr<MwmSet::MwmValueBase> Index::CreateValue(MwmInfo & info) const // Create a section with rank table if it does not exist. platform::LocalCountryFile const & localFile = info.GetLocalFile(); unique_ptr<MwmValue> p(new MwmValue(localFile)); - p->SetTable(dynamic_cast<MwmInfoEx &>(info)); ASSERT(p->GetHeader().IsMWMSuitable(), ()); return unique_ptr<MwmSet::MwmValueBase>(move(p)); } @@ -85,11 +74,11 @@ bool Index::DeregisterMap(CountryFile const & countryFile) { return Deregister(c ////////////////////////////////////////////////////////////////////////////////// Index::FeaturesLoaderGuard::FeaturesLoaderGuard(Index const & parent, MwmId const & id) - : m_handle(parent.GetMwmHandleById(id)), - /// @note This guard is suitable when mwm is loaded - m_vector(m_handle.GetValue<MwmValue>()->m_cont, - m_handle.GetValue<MwmValue>()->GetHeader(), - m_handle.GetValue<MwmValue>()->m_table) + : m_handle(parent.GetMwmHandleById(id)) + , + /// @note This guard is suitable when mwm is loaded + m_vector(m_handle.GetValue<MwmValue>()->m_cont, m_handle.GetValue<MwmValue>()->GetHeader(), + m_handle.GetValue<MwmValue>()->m_table.get()) { } |