Переглянути джерело

Merge branch 'abstract-plugin-factory-append-warnings-errors'

* abstract-plugin-factory-append-warnings-errors:
  In pluginFactory, display errors when plugin failed to load.
Jean-Christophe Fillion-Robin 13 роки тому
батько
коміт
c1c4937f9f
1 змінених файлів з 12 додано та 4 видалено
  1. 12 4
      Libs/Core/ctkAbstractPluginFactory.tpp

+ 12 - 4
Libs/Core/ctkAbstractPluginFactory.tpp

@@ -46,7 +46,12 @@ bool ctkFactoryPluginItem<BaseClassType>::load()
 {
   ctkScopedCurrentDir scopedCurrentDir(QFileInfo(this->path()).path());
   this->Loader.setFileName(this->path());
-  return this->Loader.load();
+  bool loaded = this->Loader.load();
+  if (!loaded)
+    {
+    this->appendLoadErrorString(this->loadErrorString());
+    }
+  return loaded;
 }
 
 //----------------------------------------------------------------------------
@@ -66,7 +71,7 @@ BaseClassType* ctkFactoryPluginItem<BaseClassType>::instanciator()
     {
     if (this->verbose())
       {
-      qWarning() << "Failed to instantiate plugin:" << this->path();
+      this->appendLoadErrorString(QString("Failed to instantiate plugin: %1").arg(this->path()));
       }
     return 0;
     }
@@ -75,8 +80,11 @@ BaseClassType* ctkFactoryPluginItem<BaseClassType>::instanciator()
     {
     if (this->verbose())
       {
-      qWarning() << "Failed to access interface [" << BaseClassType::staticMetaObject.className()
-               << "] in plugin:" << this->path() << "\n instead, got object of type:" << object->metaObject()->className();
+      this->appendLoadErrorString(
+            QString("Plugin %1 - Failed to access expected interface [%2] - Instead got object of type [%3]")
+            .arg(this->path())
+            .arg(BaseClassType::staticMetaObject.className())
+            .arg(object->metaObject()->className()));
       }
     delete object; // Clean memory
     return 0;