From daef6c4a39a646f8326169502147956aab4a32e8 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Sat, 16 Jan 2016 20:05:06 +0300 Subject: [PATCH] [editor] Avoid unmodified features loading loop. --- indexer/index.cpp | 7 +++++++ indexer/index.hpp | 3 +++ indexer/osm_editor.cpp | 7 +------ map/framework.cpp | 6 +++++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/indexer/index.cpp b/indexer/index.cpp index 79f7f63398..57852d456e 100644 --- a/indexer/index.cpp +++ b/indexer/index.cpp @@ -128,3 +128,10 @@ void Index::FeaturesLoaderGuard::GetFeatureByIndex(uint32_t index, FeatureType & ft.SetID(FeatureID(id, index)); } } + +void Index::FeaturesLoaderGuard::GetNotEditedFeatureByIndex(uint32_t index, FeatureType & ft) const +{ + MwmId const & id = m_handle.GetId(); + m_vector.GetByIndex(index, ft); + ft.SetID(FeatureID(id, index)); +} diff --git a/indexer/index.hpp b/indexer/index.hpp index 08b1c9474f..23418655aa 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -284,7 +284,10 @@ public: inline MwmSet::MwmId const & GetId() const { return m_handle.GetId(); } string GetCountryFileName() const; bool IsWorld() const; + /// Everyone, except Editor core, should use this method. void GetFeatureByIndex(uint32_t index, FeatureType & ft) const; + /// Editor core only method, to get 'untouched', original version of feature. + void GetNotEditedFeatureByIndex(uint32_t index, FeatureType & ft) const; inline FeaturesVector const & GetFeaturesVector() const { return m_vector; } private: diff --git a/indexer/osm_editor.cpp b/indexer/osm_editor.cpp index d818a453d2..3e1e1d89c1 100644 --- a/indexer/osm_editor.cpp +++ b/indexer/osm_editor.cpp @@ -269,7 +269,7 @@ void Editor::LoadMapEdits() uint32_t const featureIndex = mapVersion < id.GetInfo()->GetVersion() ? xml.GetMWMFeatureIndex() : MigrateFeatureIndex(xml); FeatureID const fid(id, featureIndex); - FeatureTypeInfo fti; + FeatureTypeInfo & fti = m_features[id][fid.m_index]; /// TODO(mgsergio): uncomment when feature creating will /// be required @@ -293,11 +293,6 @@ void Editor::LoadMapEdits() fti.m_uploadStatus = xml.GetUploadStatus(); fti.m_uploadError = xml.GetUploadError(); fti.m_status = section.first; - - /// Call to m_featureLoaderFn indirectly tries to load feature by - /// it's ID from the editor's m_features. - /// That's why insertion into m_features should go AFTER call to m_featureLoaderFn. - m_features[id][fid.m_index] = fti; } catch (editor::XMLFeatureError const & ex) { diff --git a/map/framework.cpp b/map/framework.cpp index 685918e2c7..39dc61cfa0 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -329,7 +329,11 @@ Framework::Framework() editor.SetInvalidateFn([this](){ InvalidateRect(GetCurrentViewport()); }); editor.SetFeatureLoaderFn([this](FeatureID const & fid) -> unique_ptr { - return GetFeatureByID(fid); + unique_ptr feature(new FeatureType()); + Index::FeaturesLoaderGuard const guard(m_model.GetIndex(), fid.m_mwmId); + guard.GetNotEditedFeatureByIndex(fid.m_index, *feature); + feature->ParseEverything(); + return feature; }); editor.LoadMapEdits(); }