keep motifs after closing window
[mussa.git] / qui / motif_editor / MotifEditor.cpp
index f98402689b3e763c41216b02fe008624109f8268..8166e37cbca86fa16092717ea12e2146aa085ac5 100644 (file)
@@ -48,14 +48,17 @@ void MotifEditor::setupWidgets()
 
 void MotifEditor::updateModel()
 {
-  MotifModel *new_model = new MotifModel(analysis);
-   
-  // if there was an old model, delete it
-  if (model) {
+  // if our current analysis doesn't match the one in our
+  // model, we probalby changed the analysis.
+  // so delete and restart
+  if (model and model->getAnalysis() != analysis) {
     delete model;
   }
-  // update the QTableView
-  model = new_model;  
+
+  // if we don't have a model, create a new one
+  if (not model) {
+    model = new MotifModel(analysis);
+  }
   table->setModel(model);
   updateView();
 }