diff main/MainWindow.cpp @ 1620:33d32b3190bf

Store aggregate models in the document and release them when they are invalidated (because their components have been released). They're no longer leaked, but we still don't save them in the session file.
author Chris Cannam
date Mon, 27 Feb 2017 16:26:37 +0000
parents 3f6c18fcc075
children 06be7469ee5f
line wrap: on
line diff
--- a/main/MainWindow.cpp	Mon Feb 27 15:44:14 2017 +0000
+++ b/main/MainWindow.cpp	Mon Feb 27 16:26:37 2017 +0000
@@ -3922,6 +3922,8 @@
         if (defaultInputModel) break;
     }
 
+    AggregateWaveModel *aggregate = 0;
+    
     if (candidateInputModels.size() > 1) {
         // Add an aggregate model as another option
         AggregateWaveModel::ChannelSpecList sl;
@@ -3933,10 +3935,9 @@
             }
         }
         if (!sl.empty()) {
-            AggregateWaveModel *aggregate = new AggregateWaveModel(sl);
+            aggregate = new AggregateWaveModel(sl);
             aggregate->setObjectName(tr("Multiplex all of the above"));
             candidateInputModels.push_back(aggregate);
-            //!!! but it leaks
         }
     }
     
@@ -3958,6 +3959,13 @@
          duration,
          &configurator);
 
+    if (input.getModel() == aggregate) {
+        m_document->addAggregateModel(aggregate);
+    } else {
+        aggregate->aboutToDelete();
+        delete aggregate;
+    }
+    
     if (!input.getModel()) return;
 
 //    SVDEBUG << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName() << "\"" << endl << "transform:" << endl << transform.toXmlString() << endl;