Revert 67338f4b35a7eb8b139531449673724534bd0a03.

This commit is contained in:
vng 2016-05-04 15:53:23 +03:00 committed by Vladimir Byko-Ianko
parent f8f27e2700
commit 8996684c19
4 changed files with 11 additions and 31 deletions

View file

@ -138,17 +138,10 @@ namespace osm
Editor::Editor() : m_notes(editor::Notes::MakeNotes()) {}
Editor * Editor::s_instance = nullptr;
Editor & Editor::Instance()
{
ASSERT(s_instance, ("nullptr dereference."));
return *s_instance;
}
void Editor::SetInstance(Editor * editor)
{
s_instance = editor;
static Editor instance;
return instance;
}
void Editor::LoadMapEdits()

View file

@ -24,6 +24,8 @@ namespace osm
{
class Editor final : public MwmSet::Observer
{
Editor();
public:
using TFeatureTypeFn = function<void(FeatureType &)>; // Mimics Framework::TFeatureTypeFn.
@ -50,10 +52,7 @@ public:
Created
};
Editor();
static Editor & Instance();
static void SetInstance(Editor * editor);
void SetMwmIdByNameAndVersionFn(TMwmIdByMapNameFn const & fn) { m_mwmIdByMapNameFn = fn; }
void SetInvalidateFn(TInvalidateFn const & fn) { m_invalidateFn = fn; }
@ -209,8 +208,6 @@ private:
/// Notes to be sent to osm.
shared_ptr<editor::Notes> m_notes;
static Editor * s_instance;
}; // class Editor
string DebugPrint(Editor::FeatureStatus fs);

View file

@ -366,13 +366,13 @@ Framework::Framework()
LOG(LINFO, ("System languages:", languages::GetPreferred()));
osm::Editor::SetInstance(&m_editor);
m_editor.SetMwmIdByNameAndVersionFn([this](string const & name) -> MwmSet::MwmId
osm::Editor & editor = osm::Editor::Instance();
editor.SetMwmIdByNameAndVersionFn([this](string const & name) -> MwmSet::MwmId
{
return m_model.GetIndex().GetMwmIdByCountryFile(platform::CountryFile(name));
});
m_editor.SetInvalidateFn([this](){ InvalidateRect(GetCurrentViewport()); });
m_editor.SetFeatureLoaderFn([this](FeatureID const & fid) -> unique_ptr<FeatureType>
editor.SetInvalidateFn([this](){ InvalidateRect(GetCurrentViewport()); });
editor.SetFeatureLoaderFn([this](FeatureID const & fid) -> unique_ptr<FeatureType>
{
unique_ptr<FeatureType> feature(new FeatureType());
Index::FeaturesLoaderGuard const guard(m_model.GetIndex(), fid.m_mwmId);
@ -380,7 +380,7 @@ Framework::Framework()
feature->ParseEverything();
return feature;
});
m_editor.SetFeatureOriginalStreetFn([this](FeatureType & ft) -> string
editor.SetFeatureOriginalStreetFn([this](FeatureType & ft) -> string
{
search::ReverseGeocoder const coder(m_model.GetIndex());
auto const streets = coder.GetNearbyFeatureStreets(ft);
@ -388,10 +388,8 @@ Framework::Framework()
return streets.first[streets.second].m_name;
return {};
});
m_editor.SetForEachFeatureAtPointFn(bind(&Framework::ForEachFeatureAtPoint, this, _1, _2));
m_editor.LoadMapEdits();
m_model.GetIndex().AddObserver(m_editor);
editor.SetForEachFeatureAtPointFn(bind(&Framework::ForEachFeatureAtPoint, this, _1, _2));
editor.LoadMapEdits();
}
Framework::~Framework()
@ -399,8 +397,6 @@ Framework::~Framework()
m_drapeEngine.reset();
m_model.SetOnMapDeregisteredCallback(nullptr);
m_model.GetIndex().RemoveObserver(m_editor);
m_editor.SetInstance(nullptr);
}
void Framework::DrawWatchFrame(m2::PointD const & center, int zoomModifier,

View file

@ -639,20 +639,14 @@ public:
public:
/// @name Editor interface.
//@{
osm::Editor const & GetEditor() const { return m_editor; };
/// Initializes feature for Create Object UI.
/// @returns false in case when coordinate is in the ocean or mwm is not downloaded.
bool CreateMapObject(m2::PointD const & mercator, uint32_t const featureType, osm::EditableMapObject & emo) const;
/// @returns false if feature is invalid or can't be edited.
bool GetEditableMapObject(FeatureID const & fid, osm:: EditableMapObject & emo) const;
osm::Editor::SaveResult SaveEditedMapObject(osm::EditableMapObject emo);
void DeleteFeature(FeatureID const & fid) const;
osm::NewFeatureCategories GetEditorCategories() const;
private:
osm::Editor m_editor;
//@}
private: