From 4e1b0e851bb97c4c2900562e5d5225335adf5c2c Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Thu, 14 Nov 2019 11:47:53 +0100 Subject: [PATCH] fix clear data when new study from button new: do not delete document when switching modules, after a new study... --- src/HYDROGUI/HYDROGUI_DataModel.cxx | 9 +-------- src/HYDROGUI/HYDROGUI_DataModel.h | 2 -- src/HYDROGUI/HYDROGUI_Module.cxx | 13 +++++++------ src/HYDROGUI/HYDROGUI_Module.h | 1 + 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 8f317862..fe650d28 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -84,7 +84,7 @@ const int ENTRY_COLUMN = 2; HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule ) -: LightApp_DataModel( theModule ), myIsAboutToClose(false) +: LightApp_DataModel( theModule ) { DEBTRACE("HYDROGUI_DataModel"); update( module()->application()->activeStudy()->id() ); @@ -219,19 +219,12 @@ bool HYDROGUI_DataModel::saveAs( const QString& theURL, bool HYDROGUI_DataModel::close() { DEBTRACE("close"); - myIsAboutToClose = true; HYDROGUI_Module* aModule = dynamic_cast( module() ); if ( aModule ) aModule->clearCache(); return true; } -bool HYDROGUI_DataModel::isAboutToClose() -{ - DEBTRACE("isAboutToClose " << myIsAboutToClose); - return myIsAboutToClose; -} - bool HYDROGUI_DataModel::dumpPython( const QString& theURL, CAM_Study* theStudy, bool isMultiFile, diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index e1a4a7ca..2b7d9217 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -86,7 +86,6 @@ public: * Close the model and remove data. Reimplemented. */ virtual bool close(); - virtual bool isAboutToClose(); /** * Dump study data to Python script. Reimplemented. @@ -388,7 +387,6 @@ protected: protected: QString myStudyURL; ///< the saved/opened document URL QByteArray myStates; - bool myIsAboutToClose; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index dc41e3e1..5ef49f3d 100755 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -109,7 +109,7 @@ #include #include -//#define _DEVDEBUG_ +#define _DEVDEBUG_ #include "HYDRO_trace.hxx" static int ViewManagerId = 0; @@ -332,14 +332,15 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy ) myViewManagerMap.clear(); bool ret = LightApp_Module::deactivateModule( theStudy ); - HYDROGUI_DataModel* aModel = getDataModel(); - if (aModel->isAboutToClose()) - { + return ret; +} + +void HYDROGUI_Module::studyClosed(SUIT_Study* theStudy) +{ + DEBTRACE("HYDROGUI_Module::studyClosed"); Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); if (!aDoc.IsNull()) aDoc->Close(); - } - return ret; } void HYDROGUI_Module::windows( QMap& theMap ) const diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index 116a351d..e39ca956 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -140,6 +140,7 @@ public: virtual void updateCommandsStatus(); virtual void selectionChanged(); + virtual void studyClosed( SUIT_Study* ); SUIT_ViewManager* getViewManager( const int theId ) const; HYDROGUI_DataModel* getDataModel() const; -- 2.39.2