Skip to content

Commit

Permalink
Fix crash while loading feature created on deleted mwm.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Magidovich authored and bykoianko committed Jun 23, 2016
1 parent fe7e960 commit 2ab4066
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
17 changes: 17 additions & 0 deletions indexer/osm_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ bool IsObsolete(editor::XMLFeature const & xml, FeatureID const & fid)
return uploadTime != my::INVALID_TIME_STAMP &&
my::TimeTToSecondsSinceEpoch(uploadTime) < GetMwmCreationTimeByMwmId(fid.m_mwmId);
}

m2::PointD GetSomeFeaturePoint(editor::XMLFeature const & xml)
{
if (xml.GetType() == XMLFeature::Type::Node)
return xml.GetMercatorCenter();
return xml.GetGeometry().front();
}
} // namespace

namespace osm
Expand Down Expand Up @@ -197,6 +204,14 @@ void Editor::LoadMapEdits()
{
XMLFeature const xml(nodeOrWay.node());

// TODO(mgsergio): A map could be renamed, we'll treat it as deleted.
// The right thing to do is to try to migrate all changes anyway.
if (!mwmId.IsAlive())
{
LOG(LINFO, ("Mwm", mapName, "was deleted"));
goto SECTION_END;
}

// TODO(mgsergio): Deleted features are not properly handled yet.
auto const fid = needMigrateEdits
? editor::MigrateFeatureIndex(
Expand Down Expand Up @@ -251,6 +266,8 @@ void Editor::LoadMapEdits()
}
} // for nodes
} // for sections
SECTION_END:
;
} // for mwms

// Save edits with new indexes and mwm version to avoid another migration on next startup.
Expand Down
4 changes: 2 additions & 2 deletions storage/country_info_getter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CountryInfoGetter
virtual ~CountryInfoGetter() = default;

// Returns country file name without an extension for a country |pt|
// belongs to. If there are no such country, returns an empty
// belongs to. If there is no such country, returns an empty
// string.
TCountryId GetRegionCountryId(m2::PointD const & pt) const;

Expand Down Expand Up @@ -72,7 +72,7 @@ class CountryInfoGetter
// Returns true if there're at least one region with id equals to
// |countryId|.
bool IsBelongToRegions(TCountryId const & countryId, TRegionIdSet const & regions) const;

void RegionIdsToCountryIds(TRegionIdSet const & regions, TCountriesVec & countries) const;

// Clears regions cache.
Expand Down
9 changes: 5 additions & 4 deletions storage/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class Storage

DownloadingPolicy m_defaultDownloadingPolicy;
DownloadingPolicy * m_downloadingPolicy = &m_defaultDownloadingPolicy;

/// @name Communicate with GUI
//@{

Expand Down Expand Up @@ -288,7 +289,7 @@ class Storage
unique_ptr<MapFilesDownloader> mapDownloaderForTesting);

void Init(TUpdateCallback const & didDownload, TDeleteCallback const & willDelete);

inline void SetDownloadingPolicy(DownloadingPolicy * policy) { m_downloadingPolicy = policy; }

/// @name Interface with clients (Android/iOS).
Expand Down Expand Up @@ -355,7 +356,7 @@ class Storage
/// \param groupNode is start of path, can't be a leaf node.
/// \param path is resulting array of TCountryId.
void GetGroupNodePathToRoot(TCountryId const & groupNode, TCountriesVec & path) const;

/// \brief Fills |nodes| with CountryIds of topmost nodes for this |countryId|.
/// For disputed territories all possible owners will be added.
void GetTopmostNodesFor(TCountryId const & countryId, TCountriesVec & nodes) const;
Expand All @@ -364,7 +365,7 @@ class Storage
inline int64_t GetCurrentDataVersion() const { return m_currentVersion; }

/// \brief Returns true if the node with countryId has been downloaded and false othewise.
/// If countryId is a expandable returns true if all mwms which belongs to it have downloaded.
/// If countryId is expandable returns true if all mwms which belongs to it have downloaded.
/// Returns false if countryId is an unknown string.
/// \note The method return false for custom maps generated by user
/// and World.mwm and WorldCoasts.mwm.
Expand Down Expand Up @@ -473,7 +474,7 @@ class Storage
/// Returns information about selected counties downloading progress.
/// |countries| - watched CountryId, ONLY leaf expected.
MapFilesDownloader::TProgress GetOverallProgress(TCountriesVec const &countries) const;

Country const & CountryLeafByCountryId(TCountryId const & countryId) const;
Country const & CountryByCountryId(TCountryId const & countryId) const;

Expand Down

0 comments on commit 2ab4066

Please sign in to comment.