소스 검색

ctkServiceReference::getPlugin now returns 0 if service was unregistered

Sascha Zelzer 14 년 전
부모
커밋
90c0e6549f
3개의 변경된 파일10개의 추가작업 그리고 15개의 파일을 삭제
  1. 5 5
      Libs/PluginFramework/ctkServiceReference.cpp
  2. 0 2
      Libs/PluginFramework/ctkServiceReference.h
  3. 5 8
      Libs/PluginFramework/ctkServiceTracker.cpp

+ 5 - 5
Libs/PluginFramework/ctkServiceReference.cpp

@@ -46,11 +46,6 @@ ctkServiceReference::~ctkServiceReference()
     delete d_ptr;
 }
 
-bool ctkServiceReference::isNull() const
-{
-  return d_func()->registration == 0;
-}
-
 QVariant ctkServiceReference::getProperty(const QString& key) const
 {
   Q_D(const ctkServiceReference);
@@ -71,6 +66,11 @@ QStringList ctkServiceReference::getPropertyKeys() const
 
 QSharedPointer<ctkPlugin> ctkServiceReference::getPlugin() const
 {
+  if (d_func()->registration == 0 || d_func()->registration->plugin == 0)
+  {
+    return QSharedPointer<ctkPlugin>();
+  }
+
   return d_func()->registration->plugin->q_func().toStrongRef();
 }
 

+ 0 - 2
Libs/PluginFramework/ctkServiceReference.h

@@ -186,8 +186,6 @@ protected:
 
   ctkServiceReference(ctkServiceRegistrationPrivate* reg);
 
-  bool isNull() const;
-
   ctkServiceReferencePrivate * d_ptr;
 
 };

+ 5 - 8
Libs/PluginFramework/ctkServiceTracker.cpp

@@ -84,12 +84,9 @@ void ctkServiceTracker::open()
         }
         else
         {
-          if (!d->trackReference.isNull())
+          if (!d->trackReference.getPlugin().isNull())
           {
-            if (d->trackReference.getPlugin())
-            {
-              references.push_back(d->trackReference);
-            }
+            references.push_back(d->trackReference);
           }
           else
           { /* user supplied filter */
@@ -153,7 +150,7 @@ void ctkServiceTracker::close()
   if (d->DEBUG)
   {
     QMutexLocker lock(&d->mutex);
-    if ((d->cachedReference.isNull()) && (d->cachedService == 0))
+    if ((d->cachedReference.getPlugin().isNull()) && (d->cachedService == 0))
     {
       qDebug() << "ctkServiceTracker::close[cached cleared]:"
           << d->filter;
@@ -214,7 +211,7 @@ ctkServiceReference ctkServiceTracker::getServiceReference() const
     QMutexLocker lock(&d->mutex);
     reference = d->cachedReference;
   }
-  if (!reference.isNull())
+  if (!reference.getPlugin().isNull())
   {
     if (d->DEBUG)
     {
@@ -340,7 +337,7 @@ QObject* ctkServiceTracker::getService() const
   try
   {
     ctkServiceReference reference = getServiceReference();
-    if (reference.isNull())
+    if (reference.getPlugin().isNull())
     {
       return 0;
     }