EXC_BAD_ACCESS in juce::ListenerList<>::call()

I’m getting a bad access here:

template <LL_TEMPLATE(1)>
    void call (void (ListenerClass::*callbackFunction) (P1), LL_PARAM(1))
    {
        for (Iterator<DummyBailOutChecker, ThisType> iter (*this); iter.next();)
            (iter.getListener()->*callbackFunction) (param1);
    }

For whatever reason, the callbackFunction argument is a garbage pointer. It’s pretty much impossible for me to debug because that method isn’t called from a traceable stack; it’s called from juce::MessageQueue::deliverNextMessage().

If I need to provide a test case, I will. What i’m doing is opening my app on a Retina screen, popping out one of the components into its own window, moving that component to my second display (non-retina) and then triggering a menu command that changes the size of that component on the other screen. The menu command ends up calling sendChangeMessage().

Could it be something like when you change from Retina-sized screens to Non-retina-sized screens that a new ComponentPeer is created?

Here’s a screenshot in XCode showing the garbage parameter being passed in.

AFAIK, the ChangeListener::changeListenerCallback isn’t being found when I change from a Retina screen to a non-retina screen. and I can’t figure out why.

My guess is that you forgot to call a needed removeChangeListener (this); somewhere
just search for addChangeListener in your code and get sure you have the matching removeChangeListener so that there is no dangling pointer left in the listener list when the listener is destroyed.

3 Likes