diff framework/Document.cpp @ 363:f5c914661f6f tonioni

Cancel async layer creation in Tony when selection is changed during it
author Chris Cannam
date Mon, 16 Jun 2014 09:28:12 +0100
parents 93cf23bfa1cb
children f1cab64363d7
line wrap: on
line diff
--- a/framework/Document.cpp	Fri Jun 13 13:51:17 2014 +0100
+++ b/framework/Document.cpp	Mon Jun 16 09:28:12 2014 +0100
@@ -275,24 +275,33 @@
         }
         vector<Layer *> layers = m_doc->createLayersForDerivedModels
             (models, names);
-        m_handler->layersCreated(m_primary, layers);
+        m_handler->layersCreated(this, m_primary, layers);
         delete this;
     }
 
     void
     noMoreModelsAvailable() {
         std::cerr << "AdditionalModelConverter::noMoreModelsAvailable" << std::endl;
-        m_handler->layersCreated(m_primary, vector<Layer *>());
+        m_handler->layersCreated(this, m_primary, vector<Layer *>());
         delete this;
     }
 
+    void cancel() {
+        foreach (Layer *layer, m_primary) {
+            Model *model = layer->getModel();
+            if (model) {
+                model->abandon();
+            }
+        }
+    }
+
 private:
     Document *m_doc;
     vector<Layer *> m_primary;
     Document::LayerCreationHandler *m_handler; //!!! how to handle destruction of this?
 };
 
-void
+Document::LayerCreationAsyncHandle
 Document::createDerivedLayersAsync(const Transforms &transforms,
                                    const ModelTransformer::Input &input,
                                    LayerCreationHandler *handler)
@@ -318,10 +327,21 @@
     if (newModels.empty()) {
         //!!! This identifier may be wrong!
         emit modelGenerationFailed(transforms[0].getIdentifier(), message);
+        //!!! what to do with amc?
     } else if (message != "") {
         //!!! This identifier may be wrong!
         emit modelGenerationWarning(transforms[0].getIdentifier(), message);
+        //!!! what to do with amc?
     }
+
+    return amc;
+}
+
+void
+Document::cancelAsyncLayerCreation(Document::LayerCreationAsyncHandle h)
+{
+    AdditionalModelConverter *conv = static_cast<AdditionalModelConverter *>(h);
+    conv->cancel();
 }
 
 vector<Layer *>