diff data/model/Model.cpp @ 1761:ee7fd2c01d87 by-id

Work on management of alignment-related models
author Chris Cannam
date Fri, 12 Jul 2019 13:57:42 +0100
parents 83178b4bb698
children aa0b56d72f27
line wrap: on
line diff
--- a/data/model/Model.cpp	Mon Jul 08 10:08:08 2019 +0100
+++ b/data/model/Model.cpp	Fri Jul 12 13:57:42 2019 +0100
@@ -25,12 +25,6 @@
 Model::~Model()
 {
     SVDEBUG << "Model::~Model: " << this << " with id " << getId() << endl;
-    //!!! see notes in header - sort this out
-    /*
-    if (!m_alignmentModel.isNone()) {
-        ModelById::release(m_alignmentModel);
-    }
-    */
 }
 
 void
@@ -50,15 +44,15 @@
 {
     SVDEBUG << "Model(" << this << "): accepting alignment model "
             << alignmentModel << endl;
-    
-    if (!m_alignmentModel.isNone()) {
-        ModelById::release(m_alignmentModel);
+
+    if (auto model = ModelById::get(m_alignmentModel)) {
+        disconnect(model.get(), SIGNAL(completionChanged(ModelId)),
+                   this, SIGNAL(alignmentCompletionChanged(ModelId)));
     }
     
     m_alignmentModel = alignmentModel;
 
-    auto model = ModelById::get(m_alignmentModel);
-    if (model) {
+    if (auto model = ModelById::get(m_alignmentModel)) {
         connect(model.get(), SIGNAL(completionChanged(ModelId)),
                 this, SIGNAL(alignmentCompletionChanged(ModelId)));
     }