changeset 1558:28d80ef79473

Report on failures that happen while configuring a transform
author Chris Cannam
date Thu, 19 Jan 2017 10:50:04 +0000
parents 5a15539f4399
children 1eb16d08c421
files .hgsubstate main/MainWindow.cpp
diffstat 2 files changed, 27 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Thu Jan 19 09:57:58 2017 +0000
+++ b/.hgsubstate	Thu Jan 19 10:50:04 2017 +0000
@@ -5,7 +5,7 @@
 d4548b18eaf20cb10045cf246af891d491c8cc32 checker
 3768bdde6fdf866aa63fff5bde8d9fa64a8979ef dataquay
 3d2cde3b1ab3d39c7f9e542250c288a9da0f6850 icons/scalable
-4413d138ed899e7baf5d214dd2f6c7f938350920 piper-cpp
+74c5013d88cd246f85710883b172592b9d0ab370 piper-cpp
 95867ba8caa86f69fdd57366dbfe2f977dd9cb5d sv-dependency-builds
 48cfa4e2bfc13b302f86ec17910249ee47cd9989 svapp
 d163b04c3ec46f8cfdbcf172e73a9dab9828792b svcore
--- a/main/MainWindow.cpp	Thu Jan 19 09:57:58 2017 +0000
+++ b/main/MainWindow.cpp	Thu Jan 19 10:50:04 2017 +0000
@@ -3881,8 +3881,17 @@
 	return;
     }
 
-    Transform transform = TransformFactory::getInstance()->
-        getDefaultTransformFor(transformId);
+    Transform transform;
+    try {
+        transform = TransformFactory::getInstance()->
+            getDefaultTransformFor(transformId);
+    } catch (std::exception &e) { // e.g. Piper server failure
+        QMessageBox::critical
+            (this, tr("Failed to query transform attributes"),
+             tr("<b>Failed to query transform attributes</b><p>Plugin or server error: %1</p>")
+             .arg(e.what()));
+        return;
+    }
 
     std::vector<Model *> candidateInputModels =
         m_document->getTransformInputModels();
@@ -3951,15 +3960,22 @@
 
 //    SVDEBUG << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName() << "\"" << endl << "transform:" << endl << transform.toXmlString() << endl;
 
-    Layer *newLayer = m_document->createDerivedLayer(transform, input);
-
-    if (newLayer) {
-        m_document->addLayerToView(pane, newLayer);
-        m_document->setChannel(newLayer, input.getChannel());
-        m_recentTransforms.add(transformId);
-        m_paneStack->setCurrentLayer(pane, newLayer);
+    try {
+        Layer *newLayer = m_document->createDerivedLayer(transform, input);
+        if (newLayer) {
+            m_document->addLayerToView(pane, newLayer);
+            m_document->setChannel(newLayer, input.getChannel());
+            m_recentTransforms.add(transformId);
+            m_paneStack->setCurrentLayer(pane, newLayer);
+        }
+    } catch (std::exception &e) { // e.g. Piper server failure
+        QMessageBox::critical
+            (this, tr("Transform failed"),
+             tr("<b>Failed to run transform</b><p>Plugin or server error: %1</p>")
+             .arg(e.what()));
+        return;
     }
-
+    
     updateMenuStates();
 }