diff data/model/Model.cpp @ 384:6f6ab834449d spectrogram-cache-rejig

* Merge from trunk
author Chris Cannam
date Wed, 27 Feb 2008 11:59:42 +0000
parents 1afaf98dbf11
children
line wrap: on
line diff
--- a/data/model/Model.cpp	Thu Nov 15 14:03:56 2007 +0000
+++ b/data/model/Model.cpp	Wed Feb 27 11:59:42 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: "
@@ -100,7 +102,7 @@
 {
     if (!m_alignment) {
         if (m_sourceModel) return m_sourceModel->getAlignmentReference();
-        return this;
+        return 0;
     }
     return m_alignment->getReferenceModel();
 }
@@ -113,9 +115,8 @@
         else return frame;
     }
     size_t refFrame = m_alignment->toReference(frame);
-    //!!! this should be totally wrong, but because alignToReference and
-    // alignFromReference are the wrong way around, it's right... *sigh*
-    if (refFrame > getEndFrame()) refFrame = getEndFrame();
+    const Model *m = m_alignment->getReferenceModel();
+    if (m && refFrame > m->getEndFrame()) refFrame = m->getEndFrame();
     return refFrame;
 }
 
@@ -127,6 +128,7 @@
         else return refFrame;
     }
     size_t frame = m_alignment->fromReference(refFrame);
+    if (frame > getEndFrame()) frame = getEndFrame();
     return frame;
 }
 
@@ -148,12 +150,21 @@
 Model::getTitle() const
 {
     if (m_sourceModel) return m_sourceModel->getTitle();
+    else return "";
 }
 
 QString
 Model::getMaker() const
 {
     if (m_sourceModel) return m_sourceModel->getMaker();
+    else return "";
+}
+
+QString
+Model::getLocation() const
+{
+    if (m_sourceModel) return m_sourceModel->getLocation();
+    else return "";
 }
 
 void