MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / loadPlugins

Method loadPlugins

ImagePlay/src/IPPluginManager.cpp:27–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27void IPPluginManager::loadPlugins(QString pluginPath, IPProcessFactory* factory)
28{
29 // plugin loading doesn't work in debug mode
30#ifdef QT_DEBUG
31 return;
32#endif
33
34#if defined(_WIN32)
35 static const auto pluginFilter = QStringList() << "*.dll";
36#else
37 static const auto pluginFilter = QStringList() << "*.so";
38#endif
39
40 qDebug() << "IPPluginManager::loadPlugins: " << pluginPath;
41
42 _pluginPath = pluginPath;
43 _factory = factory;
44 _loadedPlugins.clear();
45
46 QDir pluginsDir(_pluginPath);
47
48 // watch the original dll for changes
49 // _pluginFileSystemWatcher->addPath(pluginPath());
50
51 QDateTime now = QDateTime::currentDateTime();
52 _pluginTmpPath = _pluginPath + "/tmp/";
53 QDir tmpPluginsDir(_pluginTmpPath);
54
55 // delete old tmp directory
56 if(!removeDir(_pluginTmpPath))
57 {
58 qWarning() << "Could not remove old plugin dir: " << _pluginTmpPath;
59 return;
60 }
61
62 // create new directory, copy dlls
63 if(!tmpPluginsDir.exists())
64 tmpPluginsDir.mkpath(".");
65
66 pluginsDir.setNameFilters(pluginFilter);
67 foreach (QString fileName, pluginsDir.entryList(QDir::Files))
68 {
69 QFile file(pluginsDir.filePath(fileName));
70 file.copy(tmpPluginsDir.filePath(fileName));
71 }
72
73 if(tmpPluginsDir.exists())
74 {
75 tmpPluginsDir.setNameFilters(pluginFilter);
76
77 foreach (QString fileName, tmpPluginsDir.entryList(QDir::Files))
78 {
79 QString pluginFilePath = _pluginTmpPath + "/" + fileName;
80 pugg::Kernel* kernel = new pugg::Kernel;
81 _kernels.push_back(kernel);
82 kernel->add_server(IPLProcess::server_name(), IPLProcess::version);
83 kernel->load_plugin(pluginFilePath.toStdString());
84

Callers 2

MainWindowMethod · 0.80
reloadPluginsMethod · 0.80

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected