forked from organicmaps/organicmaps
Fixed implicit pure virtual call from destructor
This commit is contained in:
parent
a4c87d0808
commit
29d87c6e95
11 changed files with 51 additions and 14 deletions
|
@ -28,6 +28,10 @@ BackendRenderer::BackendRenderer(Params const & params)
|
|||
, m_readManager(make_unique_dp<ReadManager>(params.m_commutator, m_model))
|
||||
, m_requestedTiles(params.m_requestedTiles)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
m_isTeardowned = false;
|
||||
#endif
|
||||
|
||||
gui::DrapeGui::Instance().SetRecacheCountryStatusSlot([this]()
|
||||
{
|
||||
m_commutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
|
||||
|
@ -51,9 +55,17 @@ BackendRenderer::BackendRenderer(Params const & params)
|
|||
}
|
||||
|
||||
BackendRenderer::~BackendRenderer()
|
||||
{
|
||||
ASSERT(m_isTeardowned, ());
|
||||
}
|
||||
|
||||
void BackendRenderer::Teardown()
|
||||
{
|
||||
gui::DrapeGui::Instance().ClearRecacheCountryStatusSlot();
|
||||
StopThread();
|
||||
#ifdef DEBUG
|
||||
m_isTeardowned = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
unique_ptr<threads::IRoutine> BackendRenderer::CreateRoutine()
|
||||
|
|
|
@ -45,6 +45,8 @@ public:
|
|||
BackendRenderer(Params const & params);
|
||||
~BackendRenderer() override;
|
||||
|
||||
void Teardown();
|
||||
|
||||
protected:
|
||||
unique_ptr<threads::IRoutine> CreateRoutine() override;
|
||||
|
||||
|
@ -79,6 +81,10 @@ private:
|
|||
gui::LayerCacher m_guiCacher;
|
||||
|
||||
ref_ptr<RequestedTiles> m_requestedTiles;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool m_isTeardowned;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
|
|
@ -135,7 +135,7 @@ void BaseRenderer::ProcessStopRenderingMessage()
|
|||
CloseQueue();
|
||||
}
|
||||
|
||||
bool BaseRenderer::CanReceiveMessage()
|
||||
bool BaseRenderer::CanReceiveMessages()
|
||||
{
|
||||
return !m_selfThread.GetRoutine()->IsCancelled();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ public:
|
|||
|
||||
BaseRenderer(ThreadsCommutator::ThreadName name, Params const & params);
|
||||
|
||||
bool CanReceiveMessages();
|
||||
|
||||
void SetRenderingEnabled(bool const isEnabled);
|
||||
|
||||
protected:
|
||||
|
@ -54,11 +56,8 @@ protected:
|
|||
virtual unique_ptr<threads::IRoutine> CreateRoutine() = 0;
|
||||
|
||||
private:
|
||||
bool CanReceiveMessage() override;
|
||||
|
||||
using TCompletionHandler = function<void()>;
|
||||
|
||||
private:
|
||||
threads::Thread m_selfThread;
|
||||
ThreadsCommutator::ThreadName m_threadName;
|
||||
|
||||
|
|
|
@ -82,9 +82,13 @@ DrapeEngine::DrapeEngine(Params && params)
|
|||
|
||||
DrapeEngine::~DrapeEngine()
|
||||
{
|
||||
// reset pointers explicitly! We must wait for threads completion
|
||||
// Call Teardown and reset pointers explicitly! We must wait for threads completion.
|
||||
m_frontend->Teardown();
|
||||
m_frontend.reset();
|
||||
|
||||
m_backend->Teardown();
|
||||
m_backend.reset();
|
||||
|
||||
m_threadCommutator.reset();
|
||||
|
||||
gui::DrapeGui::Instance().Destroy();
|
||||
|
|
|
@ -55,6 +55,10 @@ FrontendRenderer::FrontendRenderer(Params const & params)
|
|||
m_fps = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
m_isTeardowned = false;
|
||||
#endif
|
||||
|
||||
ASSERT(m_tapEventInfoFn, ());
|
||||
ASSERT(m_userPositionChangedFn, ());
|
||||
|
||||
|
@ -65,8 +69,16 @@ FrontendRenderer::FrontendRenderer(Params const & params)
|
|||
}
|
||||
|
||||
FrontendRenderer::~FrontendRenderer()
|
||||
{
|
||||
ASSERT(m_isTeardowned, ());
|
||||
}
|
||||
|
||||
void FrontendRenderer::Teardown()
|
||||
{
|
||||
StopThread();
|
||||
#ifdef DEBUG
|
||||
m_isTeardowned = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DRAW_INFO
|
||||
|
|
|
@ -103,6 +103,8 @@ public:
|
|||
FrontendRenderer(Params const & params);
|
||||
~FrontendRenderer() override;
|
||||
|
||||
void Teardown();
|
||||
|
||||
#ifdef DRAW_INFO
|
||||
double m_tpf;
|
||||
double m_fps;
|
||||
|
@ -232,6 +234,10 @@ private:
|
|||
int m_currentZoomLevel = -1;
|
||||
ref_ptr<RequestedTiles> m_requestedTiles;
|
||||
uint64_t m_maxGeneration;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool m_isTeardowned;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace df
|
||||
|
|
|
@ -25,8 +25,7 @@ bool MessageAcceptor::ProcessSingleMessage(bool waitForMessage)
|
|||
|
||||
void MessageAcceptor::PostMessage(drape_ptr<Message> && message, MessagePriority priority)
|
||||
{
|
||||
if (CanReceiveMessage())
|
||||
m_messageQueue.PushMessage(move(message), priority);
|
||||
m_messageQueue.PushMessage(move(message), priority);
|
||||
}
|
||||
|
||||
void MessageAcceptor::CloseQueue()
|
||||
|
|
|
@ -18,7 +18,6 @@ protected:
|
|||
virtual ~MessageAcceptor(){}
|
||||
|
||||
virtual void AcceptMessage(ref_ptr<Message> message) = 0;
|
||||
virtual bool CanReceiveMessage() = 0;
|
||||
|
||||
/// Must be called by subclass on message target thread
|
||||
bool ProcessSingleMessage(bool waitForMessage = true);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "drape_frontend/threads_commutator.hpp"
|
||||
|
||||
#include "drape_frontend/message_acceptor.hpp"
|
||||
#include "drape_frontend/base_renderer.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
namespace df
|
||||
{
|
||||
|
||||
void ThreadsCommutator::RegisterThread(ThreadName name, MessageAcceptor * acceptor)
|
||||
void ThreadsCommutator::RegisterThread(ThreadName name, BaseRenderer * acceptor)
|
||||
{
|
||||
VERIFY(m_acceptors.insert(make_pair(name, acceptor)).second, ());
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ void ThreadsCommutator::PostMessage(ThreadName name, drape_ptr<Message> && messa
|
|||
{
|
||||
TAcceptorsMap::iterator it = m_acceptors.find(name);
|
||||
ASSERT(it != m_acceptors.end(), ());
|
||||
if (it != m_acceptors.end())
|
||||
if (it != m_acceptors.end() && it->second->CanReceiveMessages())
|
||||
it->second->PostMessage(move(message), priority);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace df
|
|||
|
||||
class Message;
|
||||
enum class MessagePriority;
|
||||
class MessageAcceptor;
|
||||
class BaseRenderer;
|
||||
|
||||
class ThreadsCommutator
|
||||
{
|
||||
|
@ -19,11 +19,11 @@ public:
|
|||
ResourceUploadThread
|
||||
};
|
||||
|
||||
void RegisterThread(ThreadName name, MessageAcceptor *acceptor);
|
||||
void RegisterThread(ThreadName name, BaseRenderer * acceptor);
|
||||
void PostMessage(ThreadName name, drape_ptr<Message> && message, MessagePriority priority);
|
||||
|
||||
private:
|
||||
typedef map<ThreadName, MessageAcceptor *> TAcceptorsMap;
|
||||
using TAcceptorsMap = map<ThreadName, BaseRenderer *>;
|
||||
TAcceptorsMap m_acceptors;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue