changeset 697:a27a6113fdd7

Restore/reimplement cancelAsyncLayerCreation - I had forgotten Tony uses it
author Chris Cannam
date Thu, 18 Jul 2019 14:12:00 +0100
parents 155008f1bf10
children 3e34eeb92647
files framework/Document.cpp framework/Document.h
diffstat 2 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Document.cpp	Wed Jul 17 14:25:41 2019 +0100
+++ b/framework/Document.cpp	Thu Jul 18 14:12:00 2019 +0100
@@ -291,6 +291,12 @@
         delete this;
     }
 
+    void cancel() {
+        foreach (Layer *layer, m_primary) {
+            m_doc->setModel(layer, {});
+        }
+    }
+
 private:
     Document *m_doc;
     vector<Layer *> m_primary;
@@ -333,6 +339,13 @@
     return amc;
 }
 
+void
+Document::cancelAsyncLayerCreation(Document::LayerCreationAsyncHandle h)
+{
+    AdditionalModelConverter *conv = static_cast<AdditionalModelConverter *>(h);
+    conv->cancel();
+}
+
 vector<Layer *>
 Document::createLayersForDerivedModels(vector<ModelId> newModels, 
                                        QStringList names)
--- a/framework/Document.h	Wed Jul 17 14:25:41 2019 +0100
+++ b/framework/Document.h	Thu Jul 18 14:12:00 2019 +0100
@@ -165,6 +165,14 @@
                                                       LayerCreationHandler *handler);
 
     /**
+     * Indicate that the async layer creation task associated with the
+     * given handle should be cancelled. There is no guarantee about
+     * what this will mean, and the handler callback may still be
+     * called.
+     */
+    void cancelAsyncLayerCreation(LayerCreationAsyncHandle handle);
+
+    /**
      * Delete the given layer, and also its associated model if no
      * longer used by any other layer.  In general, this should be the
      * only method used to delete layers -- doing so directly is a bit