Drag-and-drop checks file extensions first for plug-in candidates...
... Avoids big delays in drag-and-drop importation caused by
765ca0c813
This commit is contained in:
parent
2cdf931e5a
commit
3c9cdac778
|
@ -87,12 +87,15 @@ public:
|
|||
// DiscoverPluginsAtPath() have module-specific meaning.
|
||||
// They are not necessarily file system paths to existent files that
|
||||
// could be placed in any folder and queried for
|
||||
// plugin information. This function returns true when that is the case.
|
||||
virtual bool PathsAreFiles() = 0;
|
||||
// plugin information.
|
||||
// This function returns nonempty only when that is the case, and lists
|
||||
// the possible extensions of such files (an empty string in a nonempty
|
||||
// array means any file is a candidate).
|
||||
virtual wxArrayString FileExtensions() = 0;
|
||||
|
||||
// Returns empty, or else, where to copy a plug-in file or bundle.
|
||||
// Drag-and-drop is supported only if PathsAreFiles() is true and this
|
||||
// function returns nonempty.
|
||||
// Drag-and-drop is supported only if FileExtensions() returns nonempty and
|
||||
// this function returns nonempty.
|
||||
virtual wxString InstallPath() = 0;
|
||||
|
||||
// Modules providing a single or static set of plugins may use
|
||||
|
|
|
@ -1750,6 +1750,7 @@ void PluginManager::Terminate()
|
|||
bool PluginManager::DropFile(const wxString &fileName)
|
||||
{
|
||||
auto &mm = ModuleManager::Get();
|
||||
const wxFileName src{ fileName };
|
||||
|
||||
for (const PluginDescriptor *plug = GetFirstPlugin(PluginTypeModule);
|
||||
plug;
|
||||
|
@ -1758,7 +1759,9 @@ bool PluginManager::DropFile(const wxString &fileName)
|
|||
auto module = static_cast<ModuleInterface *>
|
||||
(mm.CreateProviderInstance(plug->GetID(), plug->GetPath()));
|
||||
const auto &ff = module->InstallPath();
|
||||
if (!ff.empty() && module->PathsAreFiles()) {
|
||||
auto extensions = module->FileExtensions();
|
||||
if (!ff.empty() &&
|
||||
make_iterator_range(extensions).contains(src.GetExt())) {
|
||||
wxString errMsg;
|
||||
// Do dry-run test of the file format
|
||||
unsigned nPlugIns =
|
||||
|
@ -1770,7 +1773,6 @@ bool PluginManager::DropFile(const wxString &fileName)
|
|||
// actions should not be tried.
|
||||
|
||||
// Find path to copy it
|
||||
const wxFileName src{ fileName };
|
||||
wxFileName dst;
|
||||
dst.AssignDir( ff );
|
||||
dst.SetFullName( src.GetFullName() );
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
bool Initialize() override;
|
||||
void Terminate() override;
|
||||
|
||||
bool PathsAreFiles() override { return false; }
|
||||
wxArrayString FileExtensions() override { return {}; }
|
||||
wxString InstallPath() override { return {}; }
|
||||
|
||||
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
|
||||
|
|
|
@ -351,6 +351,13 @@ void VSTEffectsModule::Terminate()
|
|||
return;
|
||||
}
|
||||
|
||||
wxArrayString VSTEffectsModule::FileExtensions()
|
||||
{
|
||||
static const wxString ext[] = { _T("vst") };
|
||||
static const wxArrayString result{ sizeof(ext)/sizeof(*ext), ext };
|
||||
return result;
|
||||
}
|
||||
|
||||
wxString VSTEffectsModule::InstallPath()
|
||||
{
|
||||
// Not yet ready for VST drag-and-drop...
|
||||
|
|
|
@ -391,7 +391,7 @@ public:
|
|||
bool Initialize() override;
|
||||
void Terminate() override;
|
||||
|
||||
bool PathsAreFiles() override { return true; }
|
||||
wxArrayString FileExtensions() override;
|
||||
wxString InstallPath() override;
|
||||
|
||||
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
|
||||
|
|
|
@ -140,6 +140,13 @@ wxString AudioUnitEffectsModule::GetDescription()
|
|||
// ModuleInterface implementation
|
||||
// ============================================================================
|
||||
|
||||
wxArrayString AudioUnitEffectsModule::FileExtensions()
|
||||
{
|
||||
static const wxString ext[] = { _T("au") };
|
||||
static const wxArrayString result{ sizeof(ext)/sizeof(*ext), ext };
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AudioUnitEffectsModule::Initialize()
|
||||
{
|
||||
// Nothing to do here
|
||||
|
|
|
@ -243,7 +243,7 @@ public:
|
|||
bool Initialize() override;
|
||||
void Terminate() override;
|
||||
|
||||
bool PathsAreFiles() override { return false; }
|
||||
wxArrayString FileExtensions() override;
|
||||
wxString InstallPath() override { return {}; }
|
||||
|
||||
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
|
||||
|
|
|
@ -155,6 +155,30 @@ void LadspaEffectsModule::Terminate()
|
|||
return;
|
||||
}
|
||||
|
||||
wxArrayString LadspaEffectsModule::FileExtensions()
|
||||
{
|
||||
static const wxString ext[] = {
|
||||
|
||||
#ifdef __WXMSW__
|
||||
|
||||
{ _T("dll") }
|
||||
|
||||
#else
|
||||
|
||||
{ _T("so") }
|
||||
|
||||
#ifdef __WXMAC__
|
||||
// Is it correct that these are candidate plug-in files too for macOs?
|
||||
, { _T("dylib") }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
static const wxArrayString result{ sizeof(ext)/sizeof(*ext), ext };
|
||||
return result;
|
||||
}
|
||||
|
||||
wxString LadspaEffectsModule::InstallPath()
|
||||
{
|
||||
// To do: better choice
|
||||
|
|
|
@ -223,7 +223,7 @@ public:
|
|||
bool Initialize() override;
|
||||
void Terminate() override;
|
||||
|
||||
bool PathsAreFiles() override { return true; }
|
||||
wxArrayString FileExtensions() override;
|
||||
wxString InstallPath() override;
|
||||
|
||||
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
bool Initialize() override;
|
||||
void Terminate() override;
|
||||
|
||||
bool PathsAreFiles() override { return false; }
|
||||
wxArrayString FileExtensions() override { return {}; }
|
||||
wxString InstallPath() override { return {}; }
|
||||
|
||||
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
|
||||
|
|
|
@ -160,6 +160,13 @@ void NyquistEffectsModule::Terminate()
|
|||
return;
|
||||
}
|
||||
|
||||
wxArrayString NyquistEffectsModule::FileExtensions()
|
||||
{
|
||||
static const wxString ext[] = { _T("ny") };
|
||||
static const wxArrayString result{ sizeof(ext)/sizeof(*ext), ext };
|
||||
return result;
|
||||
}
|
||||
|
||||
wxString NyquistEffectsModule::InstallPath()
|
||||
{
|
||||
return FileNames::PlugInDir();
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
bool Initialize() override;
|
||||
void Terminate() override;
|
||||
|
||||
bool PathsAreFiles() override { return true; }
|
||||
wxArrayString FileExtensions() override;
|
||||
wxString InstallPath() override;
|
||||
|
||||
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
bool Initialize() override;
|
||||
void Terminate() override;
|
||||
|
||||
bool PathsAreFiles() override { return false; }
|
||||
wxArrayString FileExtensions() override { return {}; }
|
||||
wxString InstallPath() override { return {}; }
|
||||
|
||||
bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
|
||||
|
|
Loading…
Reference in New Issue
Block a user