comparison 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
comparison
equal deleted inserted replaced
1619:44612ab2dedd 1620:33d32b3190bf
3920 } 3920 }
3921 3921
3922 if (defaultInputModel) break; 3922 if (defaultInputModel) break;
3923 } 3923 }
3924 3924
3925 AggregateWaveModel *aggregate = 0;
3926
3925 if (candidateInputModels.size() > 1) { 3927 if (candidateInputModels.size() > 1) {
3926 // Add an aggregate model as another option 3928 // Add an aggregate model as another option
3927 AggregateWaveModel::ChannelSpecList sl; 3929 AggregateWaveModel::ChannelSpecList sl;
3928 foreach (Model *m, candidateInputModels) { 3930 foreach (Model *m, candidateInputModels) {
3929 RangeSummarisableTimeValueModel *r = 3931 RangeSummarisableTimeValueModel *r =
3931 if (r) { 3933 if (r) {
3932 sl.push_back(AggregateWaveModel::ModelChannelSpec(r, -1)); 3934 sl.push_back(AggregateWaveModel::ModelChannelSpec(r, -1));
3933 } 3935 }
3934 } 3936 }
3935 if (!sl.empty()) { 3937 if (!sl.empty()) {
3936 AggregateWaveModel *aggregate = new AggregateWaveModel(sl); 3938 aggregate = new AggregateWaveModel(sl);
3937 aggregate->setObjectName(tr("Multiplex all of the above")); 3939 aggregate->setObjectName(tr("Multiplex all of the above"));
3938 candidateInputModels.push_back(aggregate); 3940 candidateInputModels.push_back(aggregate);
3939 //!!! but it leaks
3940 } 3941 }
3941 } 3942 }
3942 3943
3943 sv_frame_t startFrame = 0, duration = 0; 3944 sv_frame_t startFrame = 0, duration = 0;
3944 sv_frame_t endFrame = 0; 3945 sv_frame_t endFrame = 0;
3956 m_playSource, 3957 m_playSource,
3957 startFrame, 3958 startFrame,
3958 duration, 3959 duration,
3959 &configurator); 3960 &configurator);
3960 3961
3962 if (input.getModel() == aggregate) {
3963 m_document->addAggregateModel(aggregate);
3964 } else {
3965 aggregate->aboutToDelete();
3966 delete aggregate;
3967 }
3968
3961 if (!input.getModel()) return; 3969 if (!input.getModel()) return;
3962 3970
3963 // SVDEBUG << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName() << "\"" << endl << "transform:" << endl << transform.toXmlString() << endl; 3971 // SVDEBUG << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName() << "\"" << endl << "transform:" << endl << transform.toXmlString() << endl;
3964 3972
3965 try { 3973 try {