Occasional crash on TextButton subclass object with DragAndDrop function

Hi Juce/Roli team,

 

I occasionally had a crash on a juce function here. I attached a screenshot in when I turned on the address santinizer in xcode and caught that memory error. But I still cannot get any lead on this issue.

The crash happens (if it happens..) when I drag a TextButton subclass object which i implemented dragAndDrop function in it. More frequently happens when it is dragged onto a destination component.

 

Thanks.

 

 

/** Calls a member function on each listener in the list, with one parameter and a bail-out-checker.

        See the class description for info about writing a bail-out checker. */

    template <class BailOutCheckerType, LL_TEMPLATE(1)>

    void callChecked (const BailOutCheckerType& bailOutChecker,

                      void (ListenerClass::*callbackFunction) (P1),

                      LL_PARAM(1))

    {

        for (Iterator<BailOutCheckerType, ThisType> iter (*this); iter.next (bailOutChecker);)

            (iter.getListener()->*callbackFunction) (param1);

    }

alright,

 

It seems the trap is:

I added my editor to the global thing

 Desktop::getInstance().getAnimator().addChangeListener(this);

 

but did not remove my editor in its destructor.. And then a plugin UI close and reopen will result in this crash somehow..

 

Kinda tricky. Is there a way to prevent this kind of error from happening?

 

Thanks.

Some kind of construct like a.. "ScopedListener" would be the best in situations like this.

Not sure if it could be implemented anyway