From 6e7769f083b58608ea11d3a4d01299ac020e616b Mon Sep 17 00:00:00 2001 From: ExMix Date: Sun, 10 Aug 2014 20:20:09 +0300 Subject: [PATCH] [drape] add invalid semantic for overlay handles --- drape/overlay_handle.cpp | 5 +++++ drape/overlay_handle.hpp | 6 ++++++ drape/overlay_tree.cpp | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp index f720bdc970..18549ce18b 100644 --- a/drape/overlay_handle.cpp +++ b/drape/overlay_handle.cpp @@ -26,11 +26,16 @@ OverlayHandle::OverlayHandle(FeatureID const & id, , m_anchor(anchor) , m_priority(priority) , m_isVisible(false) + , m_isValid(true) { } bool OverlayHandle::IsVisible() const { +#ifdef DEBUG + if (m_isVisible) + ASSERT(m_isValid, ()); +#endif return m_isVisible; } diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp index 1106dffdc8..4d46a6a1fa 100644 --- a/drape/overlay_handle.hpp +++ b/drape/overlay_handle.hpp @@ -26,6 +26,8 @@ public: bool IsVisible() const; void SetIsVisible(bool isVisible); + bool IsValid() const { return m_isValid; } + virtual void Update(ScreenBase const & /*screen*/) {} virtual m2::RectD GetPixelRect(ScreenBase const & screen) const = 0; uint16_t * IndexStorage(uint16_t size); @@ -39,6 +41,9 @@ public: FeatureID const & GetFeatureID() const; double const & GetPriority() const; +protected: + void SetIsValid(bool isValid) { m_isValid = isValid; } + protected: FeatureID const m_id; dp::Anchor const m_anchor; @@ -49,6 +54,7 @@ protected: private: bool m_isVisible; + bool m_isValid; vector m_indexes; struct LessOffsetNode diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp index 172d69a1ef..b00d3cbd29 100644 --- a/drape/overlay_tree.cpp +++ b/drape/overlay_tree.cpp @@ -16,6 +16,10 @@ void OverlayTree::Add(RefPointer handle) { handle->SetIsVisible(m_canOverlap); handle->Update(m_modelView); + + if (!handle->IsValid()) + return; + m2::RectD pixelRect = handle->GetPixelRect(m_modelView); find_result_t elements;