changeset 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 44612ab2dedd
children 06be7469ee5f
files .hgsubstate main/MainWindow.cpp
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Mon Feb 27 15:44:14 2017 +0000
+++ b/.hgsubstate	Mon Feb 27 16:26:37 2017 +0000
@@ -7,7 +7,7 @@
 3d2cde3b1ab3d39c7f9e542250c288a9da0f6850 icons/scalable
 d06300b789ea62fcdc61a847b636be9d348682ef piper-cpp
 95867ba8caa86f69fdd57366dbfe2f977dd9cb5d sv-dependency-builds
-0f82c719d88548314dd5c6664a382187c82065ab svapp
+d122d3595a328054600f8ac5e78a0b34fff73af4 svapp
 1a572937ed8c24744d41f100b2233319f13402ef svcore
 3ec95b7d1bfcf8eecfcde5063328c25fc5e71b81 svgui
 fb3e0ca3e700c2dc5c75c0749dd85383b2e06da5 vamp-plugin-sdk
--- 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;