diff --git a/drape_frontend/read_mwm_task.cpp b/drape_frontend/read_mwm_task.cpp index adc039af07..dab66847c7 100644 --- a/drape_frontend/read_mwm_task.cpp +++ b/drape_frontend/read_mwm_task.cpp @@ -14,6 +14,7 @@ ReadMWMTask::ReadMWMTask(MemoryFeatureIndex & memIndex, MapDataProvider & model) void ReadMWMTask::Init(shared_ptr const & tileInfo) { m_tileInfo = tileInfo; + m_tileKey = tileInfo->GetTileKey(); #ifdef DEBUG m_checker = true; #endif @@ -29,10 +30,11 @@ void ReadMWMTask::Reset() bool ReadMWMTask::IsCancelled() const { - if (m_tileInfo == nullptr) + shared_ptr tile = m_tileInfo.lock(); + if (tile == nullptr) return true; - return m_tileInfo->IsCancelled() || IRoutine::IsCancelled(); + return tile->IsCancelled() || IRoutine::IsCancelled(); } void ReadMWMTask::Do() @@ -41,10 +43,12 @@ void ReadMWMTask::Do() ASSERT(m_checker, ()); #endif - ASSERT(m_tileInfo != nullptr, ()); + shared_ptr tile = m_tileInfo.lock(); + if (tile == nullptr) + return; try { - m_tileInfo->ReadFeatures(m_model, m_memIndex); + tile->ReadFeatures(m_model, m_memIndex); } catch (TileInfo::ReadCanceledException &) { @@ -52,10 +56,4 @@ void ReadMWMTask::Do() } } -TileKey ReadMWMTask::GetTileKey() const -{ - ASSERT(m_tileInfo != nullptr, ()); - return m_tileInfo->GetTileKey(); -} - } // namespace df diff --git a/drape_frontend/read_mwm_task.hpp b/drape_frontend/read_mwm_task.hpp index c55acab58e..c9b1051a6c 100644 --- a/drape_frontend/read_mwm_task.hpp +++ b/drape_frontend/read_mwm_task.hpp @@ -9,6 +9,7 @@ #endif #include "std/shared_ptr.hpp" +#include "std/weak_ptr.hpp" namespace df { @@ -24,10 +25,11 @@ public: void Init(shared_ptr const & tileInfo); void Reset() override; bool IsCancelled() const override; - TileKey GetTileKey() const; + TileKey const & GetTileKey() const { return m_tileKey; } private: - shared_ptr m_tileInfo; + weak_ptr m_tileInfo; + TileKey m_tileKey; MemoryFeatureIndex & m_memIndex; MapDataProvider & m_model;