KnownPluginList not movable

I’m working on scanning plugins using PluginDirectoryScanner and would prefer to synchronize my data by moving it back onto the main thread once the scan is complete, using an implementation that looks like this

mScanThread = std::make_unique<std::thread>([this]
{
    juce::VST3PluginFormat vst3Format;

    juce::KnownPluginList results;
    juce::PluginDirectoryScanner scanner(results, vst3Format, vst3Format.getDefaultLocationsToSearch(), true, juce::File());
    juce::String name;
    while(scanner.scanNextFile(true, name));
        
    juce::MessageManager::callAsync([r = std::move(results), this]
    {
        mKnownPlugins = std::move(r);
    });
});

However, since KnownPluginList is marked as non-copyable, it is implicitly non-movable, leaving me in a disappointing situation.

I don’t see any reason why this object should be non-movable, so perhaps this can be considered as a future improvement?

I think you actually need something that’s copyable (not just moveable), because MessageManager::callAsync uses std::function.

You could use a std::shared_ptr<KnownPluginList>. That’s always copyable, no matter what type it points to.

as illustrated in my code, I’m moving the object into the capture clause. If indeed the function is being copied that could cause trouble down the line, but KnownPluginList is preventing itself being moved, I cannot even create a standalone lambda with that syntax.

At any rate, your suggestion to use shared_ptr should work for this. Still disappointed, but thanks!

KnownPluginList is just a wrapper around Array<PluginDescription> and a StringArray for the blacklist.
You can just create your own custom struct of those that you pass by value, and then reconstruct the list on the other side, there are public methods for that in KnownPluginList.