fix: Fix memory leak in EventQueue

Previously empty event targets were never fully removed from EventQueue
even after unregistration. This may lead to unbounded increase of memory
use if new event targets are allocated to new memory locations.
ported: c960360106
This commit is contained in:
Povilas Kanapickas
2025-11-07 16:20:29 -05:00
committed by Chris Rizzitello
parent cbc74d99b0
commit 4728525ece

View File

@ -274,6 +274,9 @@ void EventQueue::removeHandler(EventTypes type, void *target)
if (index2 != typeHandlers.end()) {
typeHandlers.erase(index2);
}
if (typeHandlers.empty()) {
m_handlers.erase(index);
}
}
}
@ -282,7 +285,7 @@ void EventQueue::removeHandlers(void *target)
std::scoped_lock lock{m_mutex};
HandlerTable::iterator index = m_handlers.find(target);
if (index != m_handlers.end()) {
index->second.clear();
m_handlers.erase(index);
}
}