changeset 360:ac300d385ab2

* Various fixes to object lifetime management, particularly in the spectrum layer and for notification of main model deletion. The main purpose of this is to improve the behaviour of the spectrum, but I think it may also help with #1840922 Various crashes in Layer Summary window.
author Chris Cannam
date Wed, 23 Jan 2008 15:43:27 +0000
parents 824ee993ca8d
children 399ea254afd6
files data/model/FFTModel.cpp data/model/FFTModel.h data/model/Model.cpp
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/FFTModel.cpp	Tue Jan 22 23:11:48 2008 +0000
+++ b/data/model/FFTModel.cpp	Wed Jan 23 15:43:27 2008 +0000
@@ -82,6 +82,14 @@
     if (m_server) FFTDataServer::releaseInstance(m_server);
 }
 
+void
+FFTModel::sourceModelAboutToBeDeleted()
+{
+    if (m_sourceModel) {
+        FFTDataServer::modelAboutToBeDeleted(m_sourceModel);
+    }
+}
+
 FFTDataServer *
 FFTModel::getServer(const DenseTimeValueModel *model,
                     int channel,
--- a/data/model/FFTModel.h	Tue Jan 22 23:11:48 2008 +0000
+++ b/data/model/FFTModel.h	Wed Jan 23 15:43:27 2008 +0000
@@ -167,6 +167,9 @@
 
     QString getTypeName() const { return tr("FFT"); }
 
+public slots:
+    void sourceModelAboutToBeDeleted();
+
 private:
     FFTModel(const FFTModel &); // not implemented
     FFTModel &operator=(const FFTModel &); // not implemented
--- a/data/model/Model.cpp	Tue Jan 22 23:11:48 2008 +0000
+++ b/data/model/Model.cpp	Wed Jan 23 15:43:27 2008 +0000
@@ -25,7 +25,7 @@
 
 Model::~Model()
 {
-//    std::cerr << "Model::~Model(" << this << ")" << std::endl;
+    std::cerr << "Model::~Model(" << this << ")" << std::endl;
 
     if (!m_aboutToDelete) {
         std::cerr << "NOTE: Model::~Model(" << this << ", \""
@@ -66,6 +66,8 @@
 void
 Model::aboutToDelete()
 {
+    std::cerr << "Model(" << this << ")::aboutToDelete()" << std::endl;
+
     if (m_aboutToDelete) {
         std::cerr << "WARNING: Model(" << this << ", \""
                   << objectName().toStdString() << "\")::aboutToDelete: "