changeset 1384:368449629a30

Fix various "model deleted with no aboutToDelete notification" warnings (and one associated potential memory leak)
author Chris Cannam
date Wed, 22 Feb 2017 12:01:39 +0000
parents f204f2fcb15e
children b061b9f8fca5
files data/model/Dense3DModelPeakCache.cpp data/model/Model.cpp
diffstat 2 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/Dense3DModelPeakCache.cpp	Wed Feb 22 09:53:41 2017 +0000
+++ b/data/model/Dense3DModelPeakCache.cpp	Wed Feb 22 12:01:39 2017 +0000
@@ -35,11 +35,11 @@
             this, SLOT(sourceModelChanged()));
     connect(source, SIGNAL(aboutToBeDeleted()),
             this, SLOT(sourceModelAboutToBeDeleted()));
-
 }
 
 Dense3DModelPeakCache::~Dense3DModelPeakCache()
 {
+    if (m_cache) m_cache->aboutToDelete();
     delete m_cache;
 }
 
--- a/data/model/Model.cpp	Wed Feb 22 09:53:41 2017 +0000
+++ b/data/model/Model.cpp	Wed Feb 22 12:01:39 2017 +0000
@@ -27,9 +27,11 @@
 //    SVDEBUG << "Model::~Model(" << this << ")" << endl;
 
     if (!m_aboutToDelete) {
-        SVDEBUG << "NOTE: Model::~Model(" << this << ", \""
-                  << objectName() << "\"): Model deleted "
-                  << "with no aboutToDelete notification" << endl;
+        SVDEBUG << "NOTE: Model(" << this << ", \""
+                << objectName() << "\", type uri <"
+                << m_typeUri << ">)::~Model(): Model deleted "
+                << "with no aboutToDelete notification"
+                << endl;
     }
 
     if (m_alignment) {
@@ -59,13 +61,16 @@
 void
 Model::aboutToDelete()
 {
-//    cerr << "Model(" << this << ")::aboutToDelete()" << endl;
+//    SVDEBUG << "Model(" << this << ", \""
+//            << objectName() << "\", type uri <"
+//            << m_typeUri << ">)::aboutToDelete()" << endl;
 
     if (m_aboutToDelete) {
-        cerr << "WARNING: Model(" << this << ", \""
-                  << objectName() << "\")::aboutToDelete: "
-                  << "aboutToDelete called more than once for the same model"
-                  << endl;
+        SVDEBUG << "WARNING: Model(" << this << ", \""
+                << objectName() << "\", type uri <"
+                << m_typeUri << ">)::aboutToDelete: "
+                << "aboutToDelete called more than once for the same model"
+                << endl;
     }
 
     emit aboutToBeDeleted();