Sfoglia il codice sorgente

Merge branch 'fix-dynamic-cast-across-dso-boundaries'

* fix-dynamic-cast-across-dso-boundaries:
  If gcc < 4.5, load plugins with RTLD_GLOBAL during unit tests.
  Fix export macro for plugin test utility library.
  Use the usual export macro, since it has been fixed now.
  Correctly set export directives on non-Windows platforms.
  Added plugin framework property to specify load hints for plugins.
  Replaced tab with space.
Sascha Zelzer 14 anni fa
parent
commit
14951a86fa

+ 14 - 4
Libs/PluginFramework/Testing/Cpp/ctkPluginFrameworkTestUtilExport.h

@@ -25,10 +25,20 @@
 
 #include <QtCore/qglobal.h>
 
-#if defined(CTKPluginFrameworkTestUtil_EXPORTS)
- #define CTK_PLUGINFW_TESTUTIL_EXPORT Q_DECL_EXPORT
-#else
- #define CTK_PLUGINFW_TESTUTIL_EXPORT Q_DECL_IMPORT
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+#  if defined(CTKPluginFrameworkTestUtil_EXPORTS)
+#    define CTK_PLUGINFW_TESTUTIL_EXPORT Q_DECL_EXPORT
+#  else
+#    define CTK_PLUGINFW_TESTUTIL_EXPORT Q_DECL_IMPORT
+#  endif
+#endif
+
+#if !defined(CTK_PLUGINFW_TESTUTIL_EXPORT)
+//#  if defined(CTK_SHARED)
+#    define CTK_PLUGINFW_TESTUTIL_EXPORT Q_DECL_EXPORT
+//#  else
+//#    define @MY_LIBRARY_EXPORT_DIRECTIVE@
+//#  endif
 #endif
 
 #endif // CTKPLUGINFRAMEWORKTESTUTILEXPORT_H

+ 4 - 0
Libs/PluginFramework/Testing/FrameworkTest/ctkPluginFrameworkTestMain.cpp

@@ -52,6 +52,10 @@ int main(int argc, char** argv)
   fwProps.insert(ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN, ctkPluginConstants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
   fwProps.insert("pluginfw.testDir", pluginDir);
 
+#if defined(Q_CC_GNU) && ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 5)))
+  fwProps.insert(ctkPluginConstants::FRAMEWORK_PLUGIN_LOAD_HINTS, QVariant::fromValue<QLibrary::LoadHints>(QLibrary::ExportExternalSymbolsHint));
+#endif
+
   testRunner.init(fwProps);
   return testRunner.run(argc, argv);
 }

+ 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";

+ 16 - 1
Libs/PluginFramework/ctkPluginConstants.h

@@ -93,7 +93,18 @@ struct CTK_PLUGINFW_EXPORT ctkPluginConstants {
    * updates of the framework will not result in cleaning the framework
    * storage area.
    */
-  static const QString FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT; //	= "onFirstInit";
+  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.
@@ -400,5 +411,9 @@ struct CTK_PLUGINFW_EXPORT ctkPluginConstants {
 
 };
 
+#include <QLibrary>
+#include <QMetaType>
+Q_DECLARE_METATYPE(QLibrary::LoadHints)
+
 
 #endif // CTKPLUGINCONSTANTS_H

+ 1 - 1
Libs/PluginFramework/ctkPluginDatabaseException.h

@@ -27,7 +27,7 @@
 /**
  * \ingroup PluginFramework
  */
-class Q_DECL_EXPORT ctkPluginDatabaseException : public ctkRuntimeException
+class CTK_PLUGINFW_EXPORT ctkPluginDatabaseException : public ctkRuntimeException
 {
 public:
 

+ 1 - 1
Libs/PluginFramework/ctkPluginException.h

@@ -39,7 +39,7 @@
  * <p>
  * This exception conforms to the general purpose exception chaining mechanism.
  */
-class Q_DECL_EXPORT ctkPluginException : public ctkRuntimeException
+class CTK_PLUGINFW_EXPORT ctkPluginException : public ctkRuntimeException
 {
 public:
 

+ 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);

+ 1 - 1
Libs/PluginFramework/ctkRuntimeException.h

@@ -32,7 +32,7 @@
 /**
  * \ingroup PluginFramework
  */
-class Q_DECL_EXPORT ctkRuntimeException : public std::runtime_error
+class CTK_PLUGINFW_EXPORT ctkRuntimeException : public std::runtime_error
 {
 public:
 

+ 1 - 1
Libs/PluginFramework/ctkServiceException.h

@@ -38,7 +38,7 @@
  * <p>
  * This exception conforms to the general purpose exception chaining mechanism.
  */
-class Q_DECL_EXPORT ctkServiceException : public ctkRuntimeException
+class CTK_PLUGINFW_EXPORT ctkServiceException : public ctkRuntimeException
 {
 public:
 

+ 1 - 1
Libs/PluginFramework/service/cm/ctkConfigurationException.h

@@ -31,7 +31,7 @@
  * An exception class to inform the Configuration Admin service
  * of problems with configuration data.
  */
-class Q_DECL_EXPORT ctkConfigurationException : public ctkRuntimeException
+class CTK_PLUGINFW_EXPORT ctkConfigurationException : public ctkRuntimeException
 {
 
 public:

+ 14 - 4
Libs/ctkExport.h.in

@@ -10,10 +10,20 @@
 
 #include <QtCore/qglobal.h>
 
-#if defined(@MY_LIBNAME@_EXPORTS)
- #define @MY_LIBRARY_EXPORT_DIRECTIVE@ Q_DECL_EXPORT
-#else
- #define @MY_LIBRARY_EXPORT_DIRECTIVE@ Q_DECL_IMPORT
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+#  if defined(@MY_LIBNAME@_EXPORTS)
+#    define @MY_LIBRARY_EXPORT_DIRECTIVE@ Q_DECL_EXPORT
+#  else
+#    define @MY_LIBRARY_EXPORT_DIRECTIVE@ Q_DECL_IMPORT
+#  endif
+#endif
+
+#if !defined(@MY_LIBRARY_EXPORT_DIRECTIVE@)
+//#  if defined(CTK_SHARED)
+#    define @MY_LIBRARY_EXPORT_DIRECTIVE@ Q_DECL_EXPORT
+//#  else
+//#    define @MY_LIBRARY_EXPORT_DIRECTIVE@
+//#  endif
 #endif
 
 #endif