Bladeren bron

Added plugin framework property to specify load hints for plugins.

Sascha Zelzer 14 jaren geleden
bovenliggende
commit
ac40a8dba4

+ 1 - 0
Libs/PluginFramework/ctkPluginConstants.cpp

@@ -29,6 +29,7 @@ const QString ctkPluginConstants::FRAMEWORK_VENDOR = "org.commontk.pluginfw.vend
 const QString ctkPluginConstants::FRAMEWORK_STORAGE = "org.commontk.pluginfw.storage";
 const QString ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN = "org.commontk.pluginfw.storage.clean";
 const QString ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT = "onFirstInit";
+const QString ctkPluginConstants::FRAMEWORK_PLUGIN_LOAD_HINTS = "org.commontk.pluginfw.loadhints";
 
 const QString ctkPluginConstants::PLUGIN_SYMBOLICNAME = "Plugin-SymbolicName";
 const QString ctkPluginConstants::PLUGIN_COPYRIGHT = "Plugin-Copyright";

+ 15 - 0
Libs/PluginFramework/ctkPluginConstants.h

@@ -96,6 +96,17 @@ struct CTK_PLUGINFW_EXPORT ctkPluginConstants {
   static const QString FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT; // = "onFirstInit";
 
   /**
+   * Specifies the hints on how symbols in dynamic shared objects (plug-ins) are
+   * resolved. The value of this property must be of type
+   * <a href="http://doc.trolltech.com/4.7/qlibrary.html#LoadHint-enum">QLibrary::LoadHints</a>.
+   *
+   * Setting this property to QLibrary::ExportExternalSymbolsHint may
+   * be necessary on some platforms (e.g. ELF platforms with gcc < 4.5) to get
+   * RTTI working across DSO boundaries.
+   */
+  static const QString FRAMEWORK_PLUGIN_LOAD_HINTS; // = "org.commontk.pluginfw.loadhints"
+
+  /**
    * Manifest header identifying the plugin's symbolic name.
    *
    * <p>
@@ -400,5 +411,9 @@ struct CTK_PLUGINFW_EXPORT ctkPluginConstants {
 
 };
 
+#include <QLibrary>
+#include <QMetaType>
+Q_DECLARE_METATYPE(QLibrary::LoadHints)
+
 
 #endif // CTKPLUGINCONSTANTS_H

+ 11 - 0
Libs/PluginFramework/ctkPluginPrivate.cpp

@@ -48,6 +48,17 @@ ctkPluginPrivate::ctkPluginPrivate(
   //TODO
   //checkCertificates(pa);
 
+  // Get library load hints
+  if (fw->props.contains(ctkPluginConstants::FRAMEWORK_PLUGIN_LOAD_HINTS))
+  {
+    QVariant loadHintsVariant = fw->props[ctkPluginConstants::FRAMEWORK_PLUGIN_LOAD_HINTS];
+    if (loadHintsVariant.isValid())
+    {
+      QLibrary::LoadHints loadHints = loadHintsVariant.value<QLibrary::LoadHints>();
+      pluginLoader.setLoadHints(loadHints);
+    }
+  }
+
   checkManifestHeaders();
 
   pluginDir = fwCtx->getDataStorage(id);