|
@@ -86,6 +86,32 @@ void ctkPluginFrameworkContext::init()
|
|
|
services = new ctkServices(this);
|
|
|
plugins = new ctkPlugins(this);
|
|
|
|
|
|
+ // Pre-load libraries
|
|
|
+ // This may speed up installing new plug-ins if they have dependencies on
|
|
|
+ // one of these libraries. It prevents repeated loading and unloading of the
|
|
|
+ // pre-loaded libraries during caching of the plug-in meta-data.
|
|
|
+ if (props[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES].isValid())
|
|
|
+ {
|
|
|
+ QStringList preloadLibs = props[ctkPluginConstants::FRAMEWORK_PRELOAD_LIBRARIES].toStringList();
|
|
|
+ QLibrary::LoadHints loadHints;
|
|
|
+ QVariant loadHintsVariant = props[ctkPluginConstants::FRAMEWORK_PLUGIN_LOAD_HINTS];
|
|
|
+ if (loadHintsVariant.isValid())
|
|
|
+ {
|
|
|
+ loadHints = loadHintsVariant.value<QLibrary::LoadHints>();
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach(QString preloadLib, preloadLibs)
|
|
|
+ {
|
|
|
+ QLibrary lib(preloadLib);
|
|
|
+ lib.setLoadHints(loadHints);
|
|
|
+ log() << "Pre-loading library" << preloadLib << "with hints [" << static_cast<int>(loadHints) << "]";
|
|
|
+ if (!lib.load())
|
|
|
+ {
|
|
|
+ qWarning() << "Pre-loading library" << preloadLib << "failed";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
plugins->load();
|
|
|
|
|
|
log() << "inited";
|
|
@@ -219,8 +245,17 @@ void ctkPluginFrameworkContext::checkRequirePlugin(ctkPluginPrivate *plugin)
|
|
|
else if (p2->state == ctkPlugin::INSTALLED) {
|
|
|
QSet<ctkPluginPrivate*> oldTempResolved = tempResolved;
|
|
|
tempResolved.insert(p2);
|
|
|
+
|
|
|
+ // TODO check if operation locking is correct in case of
|
|
|
+ // multi-threaded plug-in start up. Maybe refactor out the dependency
|
|
|
+ // checking (use the "package" lock)
|
|
|
+ ctkPluginPrivate::Locker sync(&p2->operationLock);
|
|
|
+ p2->operation.fetchAndStoreOrdered(ctkPluginPrivate::RESOLVING);
|
|
|
checkRequirePlugin(p2);
|
|
|
tempResolved = oldTempResolved;
|
|
|
+ p2->state = ctkPlugin::RESOLVED;
|
|
|
+ listeners.emitPluginChanged(ctkPluginEvent(ctkPluginEvent::RESOLVED, p2->q_func()));
|
|
|
+ p2->operation.fetchAndStoreOrdered(ctkPluginPrivate::IDLE);
|
|
|
ok = p2;
|
|
|
}
|
|
|
}
|