What do you think about adding a getter to the MessageManager class so that users can read the messageListeners array?
I just had to debug problems related to this extremely useful assertion:
- Code: Select all
MessageManager::~MessageManager() throw()
{
...
jassert (messageListeners.size() == 0);
I ended up writing a very short getter in juce_MessageManager.h so that I could iterate through the messageListeners array and determine which components were leaking:
- Code: Select all
SortedSet <const MessageListener*> getMessageListeners() {
return messageListeners;
}
What do you think about adding this? It was extremely useful to help identify leaking components.
It allowed me to write a quick snippet in my app's shutdown() method to list all the leaking components:
- Code: Select all
SortedSet <const MessageListener*> messageListeners = MessageManager::getInstance()->getMessageListeners();
for (int i = 0; i < messageListeners.size(); i++) {
const MessageListener* messageListener = messageListeners[i];
const Component* component = dynamic_cast<const Component*> (messageListener);
if (component != 0) {
// No components should exist at this point, so if they do then they leaked
String parentName;
Component* parentComponent = component->getParentComponent();
if (parentComponent != 0) {
parentName = parentComponent->getName();
}
DBG("JuceApp::shutdown(): Leaked component " + String(i) + " found: "
+ component->getName() + " Parent: " + parentName)
}
}
Matt Sonic
