MCPcopy Create free account
hub / github.com/IChooseYou/Reclass / LoadPlugin

Method LoadPlugin

src/pluginmanager.cpp:50–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50bool PluginManager::LoadPlugin(const QString& path)
51{
52 QLibrary* library = new QLibrary(path);
53
54 // Load the library
55 if (!library->load())
56 {
57 qWarning() << "PluginManager: Failed to load plugin:" << path;
58 qWarning() << "PluginManager: Error" << library->errorString();
59 delete library;
60 return false;
61 }
62
63 // Resolve the CreatePlugin function
64 CreatePluginFunc CreateFunc = (CreatePluginFunc)library->resolve("CreatePlugin");
65 if (!CreateFunc)
66 {
67 qWarning() << "PluginManager: Plugin" << path << "does not export CreatePlugin()";
68 library->unload();
69 delete library;
70 return false;
71 }
72
73 // Create plugin instance
74 IPlugin* plugin = CreateFunc();
75 if (!plugin)
76 {
77 qWarning() << "PluginManager: CreatePlugin() returned nullptr for" << path;
78 library->unload();
79 delete library;
80 return false;
81 }
82
83 qDebug() << "PluginManager: Loaded plugin:" << plugin->Name().c_str() << plugin->Version().c_str() << "by" << plugin->Author().c_str();
84
85 // Store plugin entry
86 m_entries.append({library, plugin});
87 m_plugins.append(plugin);
88
89 // Auto-register providers in global registry
90 if (plugin->Type() == IPlugin::ProviderPlugin)
91 {
92 IProviderPlugin* provider = static_cast<IProviderPlugin*>(plugin);
93 QString name = QString::fromStdString(plugin->Name());
94 QString identifier = name.toLower().replace(" ", "");
95 ProviderRegistry::instance().registerProvider(name, identifier, provider);
96 }
97
98 return true;
99}
100
101QVector<IProviderPlugin*> PluginManager::providerPlugins() const
102{

Callers

nothing calls this directly

Calls 6

loadMethod · 0.80
TypeMethod · 0.80
registerProviderMethod · 0.80
NameMethod · 0.45
VersionMethod · 0.45
AuthorMethod · 0.45

Tested by

no test coverage detected