# HG changeset patch # User Chris Cannam # Date 1194012737 0 # Node ID 43ad8d909e2840b8ba44160be5010e464d55aabd # Parent e41af8419d4ae81fdb95afd91233241722be9ed6 * Fix #1815930 new crash, just introduced! diff -r e41af8419d4a -r 43ad8d909e28 framework/Document.cpp --- a/framework/Document.cpp Thu Nov 01 17:24:38 2007 +0000 +++ b/framework/Document.cpp Fri Nov 02 14:12:17 2007 +0000 @@ -55,7 +55,7 @@ // std::cerr << "\n\nDocument::~Document: about to clear command history" << std::endl; CommandHistory::getInstance()->clear(); -// std::cerr << "Document::~Document: about to delete layers" << std::endl; + std::cerr << "Document::~Document: about to delete layers" << std::endl; while (!m_layers.empty()) { deleteLayer(*m_layers.begin(), true); } @@ -101,6 +101,10 @@ newLayer->setObjectName(getUniqueLayerName(newLayer->objectName())); m_layers.insert(newLayer); + + std::cerr << "Document::createLayer: Added layer of type " << type + << ", now have " << m_layers.size() << " layers" << std::endl; + emit layerAdded(newLayer); return newLayer; @@ -141,6 +145,10 @@ setChannel(newLayer, -1); m_layers.insert(newLayer); + + std::cerr << "Document::createImportedLayer: Added layer of type " << type + << ", now have " << m_layers.size() << " layers" << std::endl; + emit layerAdded(newLayer); return newLayer; } @@ -248,6 +256,9 @@ // using one of these. Carry out this replacement before we // delete any of the models. + std::cerr << "Document::setMainModel: Have " + << m_layers.size() << " layers" << std::endl; + for (LayerSet::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { Layer *layer = *i; @@ -503,6 +514,9 @@ m_layers.erase(layer); + std::cerr << "Document::deleteLayer: Removing, now have " + << m_layers.size() << " layers" << std::endl; + releaseModel(layer->getModel()); emit layerRemoved(layer); emit layerAboutToBeDeleted(layer); diff -r e41af8419d4a -r 43ad8d909e28 framework/Document.h --- a/framework/Document.h Thu Nov 01 17:24:38 2007 +0000 +++ b/framework/Document.h Fri Nov 02 14:12:17 2007 +0000 @@ -119,6 +119,14 @@ QString configurationXml); /** + * Delete the given layer, and also its associated model if no + * longer used by any other layer. In general, this should be the + * only method used to delete layers -- doing so directly is a bit + * of a social gaffe. + */ + void deleteLayer(Layer *, bool force = false); + + /** * Set the main model (the source for playback sample rate, etc) * to the given wave file model. This will regenerate any derived * models that were based on the previous main model. @@ -230,14 +238,6 @@ void releaseModel(Model *model); /** - * Delete the given layer, and also its associated model if no - * longer used by any other layer. In general, this should be the - * only method used to delete layers -- doing so directly is a bit - * of a social gaffe. - */ - void deleteLayer(Layer *, bool force = false); - - /** * If model is suitable for alignment, align it against the main * model and store the alignment in the model. (If the model has * an alignment already for the current main model, leave it diff -r e41af8419d4a -r 43ad8d909e28 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Thu Nov 01 17:24:38 2007 +0000 +++ b/framework/MainWindowBase.cpp Fri Nov 02 14:12:17 2007 +0000 @@ -1126,8 +1126,7 @@ if (!il->addImage(m_viewManager->getGlobalCentreFrame(), source.getLocation())) { if (newLayer) { - m_document->setModel(il, 0); // releasing its model - delete il; + m_document->deleteLayer(il); // also releases its model } return FileOpenFailed; } else {