diff framework/SVFileReader.cpp @ 212:fe83e6e68683

* Fix crash on document deletion (new session, or application exit) after loading session with alignments
author Chris Cannam
date Sun, 24 Oct 2010 22:09:42 +0200
parents b35c7af2e1d0
children 67cea66bd588
line wrap: on
line diff
--- a/framework/SVFileReader.cpp	Sun Oct 24 17:39:00 2010 +0200
+++ b/framework/SVFileReader.cpp	Sun Oct 24 22:09:42 2010 +0200
@@ -412,8 +412,18 @@
     
     for (std::set<Model *>::iterator i = unaddedModels.begin();
          i != unaddedModels.end(); ++i) {
-        m_document->addImportedModel(*i);
-        m_addedModels.insert(*i);
+        Model *model = *i;
+        // don't want to add these models, because their lifespans
+        // are entirely dictated by the models that "own" them even
+        // though they were read independently from the .sv file.
+        // (pity we don't have a nicer way)
+        if (!dynamic_cast<PathModel *>(model) &&
+            !dynamic_cast<AlignmentModel *>(model)) {
+            m_document->addImportedModel(model);
+        }
+        // but we add all models here, so they don't get deleted
+        // when the file loader is destroyed
+        m_addedModels.insert(model);
     }
 }