diff --git a/base/fence_manager.cpp b/base/fence_manager.cpp index 55c47661d6..6f2cca66c9 100644 --- a/base/fence_manager.cpp +++ b/base/fence_manager.cpp @@ -4,7 +4,8 @@ #include "../base/logging.hpp" FenceManager::FenceManager(int conditionPoolSize) - : m_currentFence(0) + : m_currentFence(0), + m_isCancelled(false) { for (unsigned i = 0; i < conditionPoolSize; ++i) m_conditionPool.push_back(new threads::Condition()); @@ -28,6 +29,9 @@ int FenceManager::insertFence() { threads::MutexGuard g(m_mutex); + if (m_isCancelled) + return -1; + if (m_conditionPool.empty()) return -1; @@ -45,6 +49,9 @@ void FenceManager::signalFence(int id) { threads::MutexGuard g(m_mutex); + if (m_isCancelled) + return; + map::iterator it = m_activeFences.find(id); if (it == m_activeFences.end()) @@ -71,6 +78,9 @@ void FenceManager::joinFence(int id) { threads::MutexGuard g(m_mutex); + if (m_isCancelled) + return; + map::iterator it = m_activeFences.find(id); if (it == m_activeFences.end()) @@ -85,3 +95,15 @@ void FenceManager::joinFence(int id) threads::ConditionGuard g(*cond); g.Wait(); } + +void FenceManager::cancel() +{ + threads::MutexGuard g(m_mutex); + + m_isCancelled = true; + + map::iterator it = m_activeFences.begin(); + + for (; it != m_activeFences.end(); ++it) + it->second->Signal(true); +} diff --git a/base/fence_manager.hpp b/base/fence_manager.hpp index 55cb16023e..5bfdbf49a0 100644 --- a/base/fence_manager.hpp +++ b/base/fence_manager.hpp @@ -14,6 +14,7 @@ private: list m_conditionPool; map m_activeFences; int m_currentFence; + bool m_isCancelled; public: @@ -23,4 +24,5 @@ public: int insertFence(); void joinFence(int id); void signalFence(int id); + void cancel(); }; diff --git a/map/coverage_generator.cpp b/map/coverage_generator.cpp index 58a39ed58c..99875ba983 100644 --- a/map/coverage_generator.cpp +++ b/map/coverage_generator.cpp @@ -10,6 +10,8 @@ #include "../std/bind.hpp" +bool g_coverageGeneratorDestroyed = false; + CoverageGenerator::CoverageGenerator( size_t tileSize, size_t scaleEtalonSize, @@ -25,6 +27,8 @@ CoverageGenerator::CoverageGenerator( m_sequenceID(0), m_windowHandle(windowHandle) { + g_coverageGeneratorDestroyed = false; + m_resourceManager = rm; m_renderContext = primaryRC->createShared(); @@ -62,6 +66,8 @@ CoverageGenerator::~CoverageGenerator() LOG(LINFO, ("deleting currentCoverage")); delete m_currentCoverage; + + g_coverageGeneratorDestroyed = true; } void CoverageGenerator::Cancel() @@ -109,6 +115,9 @@ void CoverageGenerator::CoverScreen(ScreenBase const & screen, int sequenceID) void CoverageGenerator::AddMergeTileTask(Tiler::RectInfo const & rectInfo) { + if (g_coverageGeneratorDestroyed) + return; + m_queue.AddCommand(bind(&CoverageGenerator::MergeTile, this, rectInfo)); } diff --git a/map/tile_renderer.cpp b/map/tile_renderer.cpp index 4c0d5da6f3..ce58836b0a 100644 --- a/map/tile_renderer.cpp +++ b/map/tile_renderer.cpp @@ -159,6 +159,7 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env, drawer->clear(yg::Color(m_bgColor.r, m_bgColor.g, m_bgColor.b, 0)); drawer->screen()->setClipRect(renderRect); drawer->clear(m_bgColor); + /* drawer->clear(yg::Color(rand() % 32 + 128, rand() % 64 + 128, rand() % 32 + 128, 255)); std::stringstream out; @@ -170,7 +171,6 @@ void TileRenderer::DrawTile(core::CommandsQueue::Environment const & env, out.str().c_str(), 0, false);*/ - frameScreen.SetFromRect(m2::AnyRectD(rectInfo.m_rect)); m2::RectD selectRect; diff --git a/yg/packets_queue.cpp b/yg/packets_queue.cpp index c53f96ebad..1dfb7af13b 100644 --- a/yg/packets_queue.cpp +++ b/yg/packets_queue.cpp @@ -90,6 +90,7 @@ namespace yg void PacketsQueue::cancel() { m_packets.Cancel(); + m_fenceManager.cancel(); } void PacketsQueue::processPacket(Packet const & packet)