src: Various fixes from testing
* fixed deleted project could still be selected in the recent project menu * fixed project file not loaded when declining for reload * fixed main in tutorial description not clickable * fixed clang warnings * fixed commands not showing up in autocompletion * fixed classes were expanded when activating aggregation * fixed crash when messagelisteners tried to unregister after messagequeue was destructed
This commit is contained in:
@@ -19,8 +19,11 @@ public:
|
||||
|
||||
virtual ~MessageListenerBase()
|
||||
{
|
||||
if (m_alive)
|
||||
{
|
||||
MessageQueue::getInstance()->unregisterListener(this);
|
||||
}
|
||||
m_alive = false;
|
||||
MessageQueue::getInstance()->unregisterListener(this);
|
||||
}
|
||||
|
||||
uint getId() const
|
||||
@@ -45,6 +48,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void removedListener()
|
||||
{
|
||||
m_alive = false;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual std::string doGetType() const = 0;
|
||||
virtual void doHandleMessageBase(MessageBase*) = 0;
|
||||
|
||||
@@ -20,7 +20,12 @@ std::shared_ptr<MessageQueue> MessageQueue::getInstance()
|
||||
|
||||
MessageQueue::~MessageQueue()
|
||||
{
|
||||
// TODO: remove remaining listeners. And tell them that they shouldn't unregister anymore.
|
||||
std::lock_guard<std::mutex> lock(m_listenersMutex);
|
||||
for (size_t i = 0; i < m_listeners.size(); i++)
|
||||
{
|
||||
m_listeners[i]->removedListener();
|
||||
}
|
||||
m_listeners.clear();
|
||||
}
|
||||
|
||||
void MessageQueue::registerListener(MessageListenerBase* listener)
|
||||
|
||||
Reference in New Issue
Block a user