comparison framework/Document.h @ 588:d122d3595a32

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 b23db4cef02f
children b23bebfdfaba
comparison
equal deleted inserted replaced
587:0f82c719d885 588:d122d3595a32
27 27
28 class Model; 28 class Model;
29 class Layer; 29 class Layer;
30 class View; 30 class View;
31 class WaveFileModel; 31 class WaveFileModel;
32 class AggregateWaveModel;
32 33
33 class AdditionalModelConverter; 34 class AdditionalModelConverter;
34 35
35 class Align; 36 class Align;
36 37
232 * Add an imported (non-derived, non-main) model. This is 233 * Add an imported (non-derived, non-main) model. This is
233 * necessary to register any imported model that is associated 234 * necessary to register any imported model that is associated
234 * with a layer. 235 * with a layer.
235 */ 236 */
236 void addImportedModel(Model *); 237 void addImportedModel(Model *);
238
239 /**
240 * Add an aggregate model (one which represents a set of component
241 * wave models as one model per channel in a single wave
242 * model). Aggregate models are unusual in that they are created
243 * for a single transform each and have no refcount. (This
244 * probably isn't ideal!) They are recorded separately from other
245 * models, and will be deleted if any of their component models
246 * are removed.
247 */
248 void addAggregateModel(AggregateWaveModel *);
237 249
238 /** 250 /**
239 * Associate the given model with the given layer. The model must 251 * Associate the given model with the given layer. The model must
240 * have already been registered using one of the addXXModel 252 * have already been registered using one of the addXXModel
241 * methods above. 253 * methods above.
307 void alignmentComplete(AlignmentModel *); 319 void alignmentComplete(AlignmentModel *);
308 void alignmentFailed(QString message); 320 void alignmentFailed(QString message);
309 321
310 void activity(QString); 322 void activity(QString);
311 323
324 protected slots:
325 void aggregateModelInvalidated();
326
312 protected: 327 protected:
313 void releaseModel(Model *model); 328 void releaseModel(Model *model);
314 329
315 /** 330 /**
316 * If model is suitable for alignment, align it against the main 331 * If model is suitable for alignment, align it against the main
362 * Add an extra derived model (returned at the end of processing a 377 * Add an extra derived model (returned at the end of processing a
363 * transform). 378 * transform).
364 */ 379 */
365 void addAdditionalModel(Model *); 380 void addAdditionalModel(Model *);
366 381
382 std::set<Model *> m_aggregateModels;
383
367 class AddLayerCommand : public Command 384 class AddLayerCommand : public Command
368 { 385 {
369 public: 386 public:
370 AddLayerCommand(Document *d, View *view, Layer *layer); 387 AddLayerCommand(Document *d, View *view, Layer *layer);
371 virtual ~AddLayerCommand(); 388 virtual ~AddLayerCommand();