Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2019-04-16 20:56:30 +0300
committerTatiana Yan <tatiana.kondakova@gmail.com>2019-04-18 16:53:21 +0300
commitb2aac0af7c57fcb642593fdf2314c569e415fc71 (patch)
treed6c28a9ebfbb1910cc97a8fdf63282017068c7c7 /indexer
parent4fd525adc64ede9941e1fa2486bce85271e88f96 (diff)
[indexer][editor] crash fix for FeatureType which were created from EditableMapObjects
Diffstat (limited to 'indexer')
-rw-r--r--indexer/feature.cpp12
-rw-r--r--indexer/feature_data.cpp4
-rw-r--r--indexer/feature_data.hpp2
3 files changed, 13 insertions, 5 deletions
diff --git a/indexer/feature.cpp b/indexer/feature.cpp
index 6babbbad26..f3acd0a870 100644
--- a/indexer/feature.cpp
+++ b/indexer/feature.cpp
@@ -196,21 +196,27 @@ FeatureType::FeatureType(SharedLoadInfo const * loadInfo, Buffer buffer)
FeatureType::FeatureType(osm::MapObject const & emo)
{
- uint8_t const geomType = emo.GetGeomType();
+ EHeaderTypeMask geomType = HEADER_GEOM_POINT;
m_limitRect.MakeEmpty();
- switch (geomType)
+ switch (emo.GetGeomType())
{
+ case feature::GEOM_UNDEFINED:
+ // It is not possible because of FeatureType::GetFeatureType() never returns GEOM_UNDEFINED.
+ UNREACHABLE();
case feature::GEOM_POINT:
+ geomType = HEADER_GEOM_POINT;
m_center = emo.GetMercator();
m_limitRect.Add(m_center);
break;
case feature::GEOM_LINE:
+ geomType = HEADER_GEOM_LINE;
m_points = Points(emo.GetPoints().begin(), emo.GetPoints().end());
for (auto const & p : m_points)
m_limitRect.Add(p);
break;
case feature::GEOM_AREA:
+ geomType = HEADER_GEOM_AREA;
m_triangles = Points(emo.GetTriangesAsPoints().begin(), emo.GetTriangesAsPoints().end());
for (auto const & p : m_triangles)
m_limitRect.Add(p);
@@ -242,6 +248,8 @@ FeatureType::FeatureType(osm::MapObject const & emo)
feature::EGeomType FeatureType::GetFeatureType() const
{
+ // FeatureType::FeatureType(osm::MapObject const & emo) expects
+ // that GEOM_UNDEFINED is never be returned.
switch (m_header & HEADER_GEOTYPE_MASK)
{
case HEADER_GEOM_LINE: return GEOM_LINE;
diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp
index 0ba2844a2c..b40492f25d 100644
--- a/indexer/feature_data.cpp
+++ b/indexer/feature_data.cpp
@@ -131,7 +131,7 @@ private:
namespace feature
{
-uint8_t CalculateHeader(size_t const typesCount, uint8_t const headerGeomType,
+uint8_t CalculateHeader(size_t const typesCount, EHeaderTypeMask const headerGeomType,
FeatureParamsBase const & params)
{
ASSERT(typesCount != 0, ("Feature should have at least one type."));
@@ -562,7 +562,7 @@ bool FeatureParams::CheckValid() const
uint8_t FeatureParams::GetHeader() const
{
- return CalculateHeader(m_types.size(), GetTypeMask(), *this);
+ return CalculateHeader(m_types.size(), static_cast<EHeaderTypeMask>(GetTypeMask()), *this);
}
uint32_t FeatureParams::GetIndexForType(uint32_t t)
diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp
index f69bb11b8a..66bb716c50 100644
--- a/indexer/feature_data.hpp
+++ b/indexer/feature_data.hpp
@@ -126,7 +126,7 @@ namespace feature
std::string DebugPrint(TypesHolder const & holder);
- uint8_t CalculateHeader(size_t const typesCount, uint8_t const headerGeomType,
+ uint8_t CalculateHeader(size_t const typesCount, EHeaderTypeMask const headerGeomType,
FeatureParamsBase const & params);
} // namespace feature