Skip to content

Commit

Permalink
Plugin bundle validation fix (plugin contains multiple effects)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsverchinsky committed Sep 22, 2022
1 parent 10156c3 commit 135773c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
17 changes: 13 additions & 4 deletions libraries/lib-module-manager/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,20 @@ namespace
//Workaround: use DefaultRegistrationCallback to create all descriptors for us
//and then put a copy into result
auto id = PluginManager::DefaultRegistrationCallback(provider, ident);
if(const auto desc = PluginManager::Get().GetPlugin(id))
if(const auto ptr = PluginManager::Get().GetPlugin(id))
{
if(validator)
validator->Validate(*ident);
result.Add(PluginDescriptor { *desc });
auto desc = *ptr;
try
{
if(validator)
validator->Validate(*ident);
}
catch(...)
{
desc.SetEnabled(false);
desc.SetValid(false);
}
result.Add(std::move(desc));
}
return id;
});
Expand Down
28 changes: 21 additions & 7 deletions src/PluginStartupRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ void PluginStartupRegistration::OnPluginFound(const PluginDescriptor& desc)
else
{
mValidProviderFound = true;
if(!desc.IsValid())
mFailedPluginsCache.push_back(desc);
PluginManager::Get().RegisterPlugin(PluginDescriptor { desc });
}
}
Expand All @@ -52,14 +54,26 @@ void PluginStartupRegistration::OnValidationFinished()
if(mValidProviderFound ||
mPluginsToProcess[mCurrentPluginIndex].second.size() == mCurrentPluginProviderIndex)
{
//we've tried all providers associated with same module path...
if(!mValidProviderFound && !mFailedPluginsCache.empty())
if(!mFailedPluginsCache.empty())
{
//...but none of them succeeded
mFailedPluginsPaths.push_back(mFailedPluginsCache[0].GetPath());

for(auto& desc : mFailedPluginsCache)
PluginManager::Get().RegisterPlugin(std::move(desc));
//we've tried all providers associated with same module path...
if(!mValidProviderFound)
{
//...but none of them succeeded
mFailedPluginsPaths.push_back(mFailedPluginsCache[0].GetPath());

for(auto& desc : mFailedPluginsCache)
PluginManager::Get().RegisterPlugin(std::move(desc));
}
//plugin type was detected, but provider wasn't able to validate it
else
{
for(auto& desc : mFailedPluginsCache)
{
if(desc.GetPluginType() != PluginTypeStub)
mFailedPluginsPaths.push_back(desc.GetPath());
}
}
}
++mCurrentPluginIndex;
mCurrentPluginProviderIndex = 0;
Expand Down

0 comments on commit 135773c

Please sign in to comment.