changeset 79:b1a68403714b

* Further model lifecycle fixes
author Chris Cannam
date Thu, 24 Jan 2008 11:03:59 +0000
parents 58bfaaed07ed
children 448ff6e34b99
files framework/Document.cpp framework/MainWindowBase.cpp framework/SVFileReader.cpp framework/SVFileReader.h
diffstat 4 files changed, 34 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Document.cpp	Wed Jan 23 18:09:50 2008 +0000
+++ b/framework/Document.cpp	Thu Jan 24 11:03:59 2008 +0000
@@ -79,8 +79,8 @@
 		std::cerr << "Document::~Document: WARNING: Main model is also"
 			  << " in models list!" << std::endl;
 	    } else if (model) {
+                model->aboutToDelete();
 		emit modelAboutToBeDeleted(model);
-                model->aboutToDelete();
 		delete model;
 	    }
 	    m_models.erase(m_models.begin());
@@ -92,8 +92,8 @@
 	      << std::endl;
 #endif
     if (m_mainModel) {
+        m_mainModel->aboutToDelete();
         emit modelAboutToBeDeleted(m_mainModel);
-        m_mainModel->aboutToDelete();
     }
 
     emit mainModelChanged(0);
@@ -377,8 +377,8 @@
     }
 
     if (oldMainModel) {
+        oldMainModel->aboutToDelete();
         emit modelAboutToBeDeleted(oldMainModel);
-        oldMainModel->aboutToDelete();
     }
 
     emit mainModelChanged(m_mainModel);
@@ -509,8 +509,8 @@
 		      << "their source fields appropriately" << std::endl;
 	}
 
+        model->aboutToDelete();
 	emit modelAboutToBeDeleted(model);
-        model->aboutToDelete();
 	m_models.erase(model);
 	delete model;
     }
--- a/framework/MainWindowBase.cpp	Wed Jan 23 18:09:50 2008 +0000
+++ b/framework/MainWindowBase.cpp	Thu Jan 24 11:03:59 2008 +0000
@@ -1088,6 +1088,12 @@
         }
         
         SVFileReader reader(m_document, callback, source.getLocation());
+        connect
+            (&reader, SIGNAL(modelRegenerationFailed(QString, QString, QString)),
+             this, SLOT(modelRegenerationFailed(QString, QString, QString)));
+        connect
+            (&reader, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
+             this, SLOT(modelRegenerationWarning(QString, QString, QString)));
         reader.setCurrentPane(pane);
         
         QXmlInputSource inputSource(&file);
@@ -1222,6 +1228,12 @@
     m_viewManager->clearSelections();
 
     SVFileReader reader(m_document, callback, source.getLocation());
+    connect
+        (&reader, SIGNAL(modelRegenerationFailed(QString, QString, QString)),
+         this, SLOT(modelRegenerationFailed(QString, QString, QString)));
+    connect
+        (&reader, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
+         this, SLOT(modelRegenerationWarning(QString, QString, QString)));
     QXmlInputSource inputSource(&bzFile);
     reader.parse(inputSource);
     
--- a/framework/SVFileReader.cpp	Wed Jan 23 18:09:50 2008 +0000
+++ b/framework/SVFileReader.cpp	Thu Jan 24 11:03:59 2008 +0000
@@ -308,7 +308,15 @@
                      ModelTransformer::Input(m_currentTransformSource,
                                              m_currentTransformChannel),
                      message);
-                //!!! do something with message
+                if (!m_currentDerivedModel) {
+                    emit modelRegenerationFailed(tr("(derived model in SV-XML)"),
+                                                 m_currentTransform.getIdentifier(),
+                                                 message);
+                } else if (message != "") {
+                    emit modelRegenerationWarning(tr("(derived model in SV-XML)"),
+                                                  m_currentTransform.getIdentifier(),
+                                                  message);
+                }                    
             }
         } else {
             m_document->addDerivedModel
--- a/framework/SVFileReader.h	Wed Jan 23 18:09:50 2008 +0000
+++ b/framework/SVFileReader.h	Thu Jan 24 11:03:59 2008 +0000
@@ -161,8 +161,10 @@
  */
 
 
-class SVFileReader : public QXmlDefaultHandler
+class SVFileReader : public QObject, QXmlDefaultHandler
 {
+    Q_OBJECT
+
 public:
     SVFileReader(Document *document,
 		 SVFileReaderPaneCallback &callback,
@@ -192,6 +194,12 @@
     bool error(const QXmlParseException &exception);
     bool fatalError(const QXmlParseException &exception);
 
+signals:
+    void modelRegenerationFailed(QString layerName, QString transformName,
+                                 QString message);
+    void modelRegenerationWarning(QString layerName, QString transformName,
+                                  QString message);
+
 protected:
     bool readWindow(const QXmlAttributes &);
     bool readModel(const QXmlAttributes &);