Forráskód Böngészése

Warn, but do not throw exceptions if dah plugins cannot start

Ivo Wolf 13 éve
szülő
commit
2b2afadbf0

+ 7 - 1
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic.cpp

@@ -53,7 +53,13 @@ ctkDicomAbstractApp(ctkExampleDicomAppPlugin::getPluginContext()), AppWidget(0)
   connect(this, SIGNAL(exitHostedApp()), this, SLOT(onExitHostedApp()), Qt::QueuedConnection);
 
   //notify Host we are ready.
-  getHostInterface()->notifyStateChanged(ctkDicomAppHosting::IDLE);
+  try {
+    getHostInterface()->notifyStateChanged(ctkDicomAppHosting::IDLE);
+  }
+  catch(...)
+  {
+    qDebug() << "ctkDicomAbstractApp: Could not getHostInterface()";
+  }
 }
 
 //----------------------------------------------------------------------------

+ 16 - 8
Plugins/org.commontk.dah.hostedapp/ctkDicomAppPlugin.cpp

@@ -52,27 +52,35 @@ ctkDicomAppPlugin::~ctkDicomAppPlugin()
 //----------------------------------------------------------------------------
 void ctkDicomAppPlugin::start(ctkPluginContext* context)
 {
-  ctkDicomAppPlugin::Context = context;
+  bool canStart = true;
 
+  ctkDicomAppPlugin::Context = context;
 
   QUrl appURL(context->getProperty("dah.appURL").toString());
   if (!appURL.isValid())
     {
-    throw std::runtime_error("The plugin framework does not contain a valid \"dah.appURL\" property");
+    //throw std::runtime_error("The plugin framework does not contain a valid \"dah.appURL\" property");
+    qDebug() << "ctkDicomAppPlugin: The plugin framework does not contain a valid \"dah.appURL\" property";
+    canStart = false;
     }
 
   QUrl hostURL(context->getProperty("dah.hostURL").toString());
   if (!hostURL.isValid())
     {
-    throw std::runtime_error("The plugin framework does not contain a valid \"dah.hostURL\" property");
+    //throw std::runtime_error("The plugin framework does not contain a valid \"dah.hostURL\" property");
+    qDebug() << "ctkDicomAppPlugin: The plugin framework does not contain a valid \"dah.hostURL\" property";
+    canStart = false;
     }
 
-  // start the application server
-  this->AppServer = new ctkDicomAppServer(appURL.port(), appURL.path());
+  if(canStart)
+    {
+    // start the application server
+    this->AppServer = new ctkDicomAppServer(appURL.port(), appURL.path());
 
-  // register the host service, providing callbacks to the hosting application
-  this->HostInterface = new ctkDicomHostService(QUrl(hostURL).port(), hostURL.path());
-  context->registerService<ctkDicomHostInterface>(HostInterface);
+    // register the host service, providing callbacks to the hosting application
+    this->HostInterface = new ctkDicomHostService(QUrl(hostURL).port(), hostURL.path());
+    context->registerService<ctkDicomHostInterface>(HostInterface);
+    }
 }
 
 //----------------------------------------------------------------------------