Skip to content

Commit 4cb31d0

Browse files
alxbilgerhugtalbot
andauthored
register objects from auto-loaded plugins (#513)
Co-authored-by: Hugo <[email protected]>
1 parent 1abf7ac commit 4cb31d0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bindings/SofaRuntime/src/SofaPython3/SofaRuntime/Module_SofaRuntime.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,25 @@ PYBIND11_MODULE(SofaRuntime, m) {
132132
{
133133
std::string configPluginPath = "plugin_list.conf";
134134
std::string defaultConfigPluginPath = "plugin_list.conf.default";
135+
136+
sofa::type::vector<std::string> loadedPlugins;
135137
if (sofa::helper::system::PluginRepository.findFile(configPluginPath, "", nullptr))
136138
{
137139
msg_info("SofaRuntime") << "Loading automatically plugin list in " << configPluginPath;
138-
sofa::helper::system::PluginManager::getInstance().readFromIniFile(configPluginPath);
140+
sofa::helper::system::PluginManager::getInstance().readFromIniFile(configPluginPath, loadedPlugins);
139141
}
140142
if (sofa::helper::system::PluginRepository.findFile(defaultConfigPluginPath, "", nullptr))
141143
{
142144
msg_info("SofaRuntime") << "Loading automatically plugin list in " << defaultConfigPluginPath;
143-
sofa::helper::system::PluginManager::getInstance().readFromIniFile(defaultConfigPluginPath);
145+
sofa::helper::system::PluginManager::getInstance().readFromIniFile(defaultConfigPluginPath, loadedPlugins);
146+
}
147+
148+
if (sofa::core::ObjectFactory* objectFactory = sofa::core::ObjectFactory::getInstance())
149+
{
150+
for (const auto& pluginName : loadedPlugins)
151+
{
152+
objectFactory->registerObjectsFromPlugin(pluginName);
153+
}
144154
}
145155
}, "automatically load plugins from configuration files");
146156

0 commit comments

Comments
 (0)