Browse Source

Merge branch 'plugin-fw-fixes'

* plugin-fw-fixes:
  Work around different wchar_t settings.
  Use ascii ' instead of unicode ’ in file ctkEventAdmin.h
  Use unicode version FormatMessageW in ctkPluginFrameworkLauncher::appendPathEnv
  Break the #include <QtSql> into #include <QLibrary> #include <QSqlQuery> #include <QDebug> #include <QSqlError> #include <QPluginLoader> #include <QDirIterator> because QtSql pulls the <Windows.h> and that will define the REGISTERED macro.
  qRegisterMetaType ctkServiceReference and QSharedPointer<ctkPlugin>, because the weakness of Qt MetaType system, we need to register type early.
  Add the lost Q_D(const PluginTracker); in ctkPluginTracker<T>::isEmpty()
  It's should return T() but QVariant().
  Move the REGISTERED macro check to the front of the ctkServiceEvent file.
Sascha Zelzer 11 years ago
parent
commit
49a211d1cb

+ 3 - 0
Libs/PluginFramework/ctkPluginFramework.cpp

@@ -38,6 +38,9 @@ ctkPluginFramework::ctkPluginFramework()
   qRegisterMetaType<ctkEvent>("ctkEvent");
   qRegisterMetaType<ctkProperties>("ctkProperties");
   qRegisterMetaType<ctkDictionary>("ctkDictionary");
+  qRegisterMetaType<ctkServiceReference>("ctkServiceReference");
+  qRegisterMetaType<QSharedPointer<ctkPlugin> >("QSharedPointer<ctkPlugin>");
+  //TODO: register all ctk Framework defined MetaType.
 }
 
 //----------------------------------------------------------------------------

+ 7 - 3
Libs/PluginFramework/ctkPluginFrameworkLauncher.cpp

@@ -267,18 +267,22 @@ void ctkPluginFrameworkLauncher::appendPathEnv(const QString& path)
     LPVOID lpMsgBuf;
     DWORD dw = GetLastError();
 
-    FormatMessage(
+    FormatMessageW(
         FORMAT_MESSAGE_ALLOCATE_BUFFER |
         FORMAT_MESSAGE_FROM_SYSTEM |
         FORMAT_MESSAGE_IGNORE_INSERTS,
         NULL,
         dw,
         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-        (LPTSTR) &lpMsgBuf,
+        (LPWSTR) &lpMsgBuf,
         0, NULL );
 
+    // Avoid project configuration conflicts regarding wchar_t considered
+    // a built-in type or not by using QString::fromUtf16 instead of
+    // QString::fromWCharArray
+    // sa http://qt-project.org/wiki/toStdWStringAndBuiltInWchar
     QString msg = QString("Adding '%1' to the PATH environment variable failed: %2")
-      .arg(path).arg(QString((LPCTSTR)lpMsgBuf));
+      .arg(path).arg(QString::fromUtf16(reinterpret_cast<const ushort*>(lpMsgBuf)));
 
     qWarning() << msg;
 

+ 7 - 1
Libs/PluginFramework/ctkPluginStorageSQL_p.h

@@ -24,7 +24,13 @@
 
 #include "ctkPluginStorage_p.h"
 
-#include <QtSql>
+#include <QMutex>
+#include <QLibrary>
+#include <QSqlQuery>
+#include <QDebug>
+#include <QSqlError>
+#include <QPluginLoader>
+#include <QDirIterator>
 
 // CTK class forward declarations
 class ctkPluginFrameworkContext;

+ 2 - 1
Libs/PluginFramework/ctkPluginTracker.tpp

@@ -143,7 +143,7 @@ T ctkPluginTracker<T>::getObject(QSharedPointer<ctkPlugin> plugin) const
   QSharedPointer<TrackedPlugin> t = d->tracked();
   if (t.isNull())
   {
-    return QVariant();
+    return T();
   }
 
   {
@@ -220,6 +220,7 @@ QMap<QSharedPointer<ctkPlugin>, T> ctkPluginTracker<T>::getTracked() const
 template<class T>
 bool ctkPluginTracker<T>::isEmpty() const
 {
+  Q_D(const PluginTracker);
   QSharedPointer<TrackedPlugin> t = d->tracked();
   if (t.isNull())
   { /* if PluginTracker is not open */

+ 7 - 8
Libs/PluginFramework/ctkServiceEvent.h

@@ -22,23 +22,22 @@
 #ifndef CTKSERVICEEVENT_H
 #define CTKSERVICEEVENT_H
 
+#ifdef REGISTERED
+#error Try to reorder include files (this one first)\
+ or write #undef REGISTERED before including this header.\
+ Cause of this problem may be dcmimage.h, which indirectly\
+ includes windows.h.
+#endif
+
 #include <QSharedDataPointer>
 #include <QDebug>
 #include <QMetaType>
 
 #include "ctkPluginFrameworkExport.h"
-
 #include "ctkServiceReference.h"
 
 class ctkServiceEventData;
 
-#ifdef REGISTERED
-#error Try to reorder include files (this one first)\
- or write #undef REGISTERED before including this header.\
- Cause of this problem may be dcmimage.h, which indirectly\
- includes windows.h.
-#endif
-
 /**
  * \ingroup PluginFramework
  *

+ 2 - 2
Libs/PluginFramework/service/event/ctkEventAdmin.h

@@ -114,7 +114,7 @@ struct ctkEventAdmin
    *
    * Slots should be registered with a property ctkEventConstants::EVENT_TOPIC.
    * The value being a QString or QStringList object that describes which
-   * topics the slot is interested in. A wildcard (’*’ \\u002A) may be used as
+   * topics the slot is interested in. A wildcard ('*' \\u002A) may be used as
    * the last token of a topic name, for example com/action&#47*. This matches any
    * topic that shares the same first tokens. For example, com/action&#47* matches
    * com/action/listen. Slots which have not been specified with the EVENT_TOPIC
@@ -122,7 +122,7 @@ struct ctkEventAdmin
    * The value of each entry in the EVENT_TOPIC property must conform to the
    * following grammar:
    * \verbatim
-   * topic-scope ::= ’*’ | ( topic ’&#47*’ ? )
+   * topic-scope ::= '*' | ( topic '&#47*' ? )
    * \endverbatim
    *
    * Slots can also be registered with a property named ctkEventConstants::EVENT_FILTER.