createPluginInstanceAsync never fires callback

Hi!
I use the following code. But callback function is never fired. Why?

addPlugin(const PluginDescription& desc){
    
    double sampleRate = 48000;
    int blockSize = 512;
 
    // THIS WORKS:
    //String error;
    //auto instance = formatManager.createPluginInstance(desc, sampleRate, blockSize, error);
    
    // THIS RUNS WITH NO ERROR, WITH NO CALLBACK
    formatManager.createPluginInstanceAsync(desc,
                                            sampleRate,
                                            blockSize,
                                            [this](std::unique_ptr<AudioPluginInstance> instance, const String& error){
                                                addPluginCallback(std::move(instance), error);
    });
}

void PluginGraph::addPluginCallback(std::unique_ptr<AudioPluginInstance> instance, const String& error){
    // break point here is never hit.  
}

Please help.

Solved:
problem was that I have called methods of class which was instantiated inside a method, and at time of callback was disposed.

Thank you.

1 Like