ChangeListener add failed

It would, if you didn’t immediately destroy the initializer because that causes the Juce MessageManager/GUI to shutdown again.

I am not sure what would the best pattern in your use case, but could be simpler to just call initialiseJuce_GUI very early in your C++ code and when you are no longer going to need to Juce, then call shutdownJuce_GUI.

It worked, i call initialize, add the listener, then destroy it, no more assertion error. But the changeListenerCallback did not invoked when the audio is finished

I got this assertion error in AsyncUpdater. Maybe it also need a MessageManager instance exists to work:

I think it wasn’t mentioned before, those “ScopedFoo” are meant to be added onto the stack. If you create them with new it defeats the purpose of the RAII pattern.

The ScopedJuceInitialiser_GUI initialises stuff in the constructor and deinitialises/cleans up in the destructor.

You use it like so:

int main(int, char**)
{
    const juce::ScopedJuceInitialiser_GUI initialiser;

    // do your stuff

    // at the end of the scope all local variables are destroyed, 
    // so the last thing that will happen is the automatic de-initialising 
    // of the juce machinery
}

Note that despite the name, the ScopedJuceInitialiser_GUI doesn’t do anything GUI specific, or at least not graphical/window specific. This only happens when you add a Component to the desktop.

2 Likes