forked from organicmaps/organicmaps
Free tile info immediately on cancel.
This commit is contained in:
parent
486532f44f
commit
15f499dcbd
2 changed files with 12 additions and 12 deletions
|
@ -14,6 +14,7 @@ ReadMWMTask::ReadMWMTask(MemoryFeatureIndex & memIndex, MapDataProvider & model)
|
|||
void ReadMWMTask::Init(shared_ptr<TileInfo> 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<TileInfo> 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<TileInfo> 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
|
||||
|
|
|
@ -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<TileInfo> const & tileInfo);
|
||||
void Reset() override;
|
||||
bool IsCancelled() const override;
|
||||
TileKey GetTileKey() const;
|
||||
TileKey const & GetTileKey() const { return m_tileKey; }
|
||||
|
||||
private:
|
||||
shared_ptr<TileInfo> m_tileInfo;
|
||||
weak_ptr<TileInfo> m_tileInfo;
|
||||
TileKey m_tileKey;
|
||||
MemoryFeatureIndex & m_memIndex;
|
||||
MapDataProvider & m_model;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue