[editor] Avoid unmodified features loading loop.

This commit is contained in:
Alex Zolotarev 2016-01-16 20:05:06 +03:00 committed by Sergey Yershov
parent 199189a68b
commit daef6c4a39
4 changed files with 16 additions and 7 deletions

View file

@ -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));
}

View file

@ -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:

View file

@ -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)
{

View file

@ -329,7 +329,11 @@ Framework::Framework()
editor.SetInvalidateFn([this](){ InvalidateRect(GetCurrentViewport()); });
editor.SetFeatureLoaderFn([this](FeatureID const & fid) -> unique_ptr<FeatureType>
{
return GetFeatureByID(fid);
unique_ptr<FeatureType> 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();
}