Salome HOME
[bos#35161][EDF](2023-T1) Automatic backup - initial commit
authormbs <martin.bernhard@opencascade.com>
Sat, 9 Dec 2023 22:21:12 +0000 (22:21 +0000)
committermbs <martin.bernhard@opencascade.com>
Fri, 19 Jan 2024 23:08:16 +0000 (23:08 +0000)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_DataModel.cxx
src/LightApp/LightApp_DataModel.h
src/LightApp/LightApp_Study.cxx
src/LightApp/LightApp_Study.h
src/SUIT/SUIT_Study.cxx
src/SUIT/SUIT_Study.h
src/SalomeApp/SalomeApp_Study.cxx
src/SalomeApp/SalomeApp_Study.h

index f14da6ff25ccff976d5d3159a9e5b720601da95f..7be6a4c19d412294c21b3f8def6d0e53e3c21317 100644 (file)
 
 #include <Standard_Version.hxx>
 
+//---------------------------------------------------------
+#define USE_DEBUG
+//#define MB_IGNORE_QT
+//#define MB_FULL_DUMP
+#define MBCLASSNAME "LightApp_Application"
+#include "MBDebug.h"
+// <-- insert includes for addtional debug headers here!
+//---------------------------------------------------------
+
 #define ToolBarMarker    0
 #define DockWidgetMarker 1
 
@@ -373,6 +382,7 @@ LightApp_Application::LightApp_Application()
   myPrefs( 0 ),
   myScreenHelper(new LightApp_FullScreenHelper())
 {
+  DBG_FUN();
   Q_INIT_RESOURCE( LightApp );
 
   STD_TabDesktop* desk = new STD_TabDesktop();
@@ -485,6 +495,7 @@ LightApp_Application::LightApp_Application()
  */
 LightApp_Application::~LightApp_Application()
 {
+  DBG_FUN();
   savePreferences();
   delete mySelMgr;
   delete myScreenHelper;
@@ -494,6 +505,7 @@ LightApp_Application::~LightApp_Application()
 /*!Start application.*/
 void LightApp_Application::start()
 {
+  DBG_FUN();
   CAM_Application::start();
 
   updateWindows();
@@ -511,6 +523,7 @@ void LightApp_Application::start()
 /*!Closeapplication.*/
 void LightApp_Application::closeApplication()
 {
+  DBG_FUN();
 #ifndef DISABLE_QTXWEBBROWSER
   QProcess::startDetached( "HelpBrowser",
                            QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
@@ -2219,6 +2232,7 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
 */
 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
 {
+  DBG_FUN();
   SUIT_DataObject* aRoot = 0;
   if ( theStudy && theStudy->root() )
   {
@@ -2250,9 +2264,12 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
 /*!Protected SLOT. On study saved.*/
 void LightApp_Application::onStudySaved( SUIT_Study* s )
 {
+  DBG_FUN();
   QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
-  if ( mru && s )
+  if ( mru && s ) {
+    MSGEL("...adding [" << s->studyName().toStdString() << "] to MRU");
     mru->insert( s->studyName() );
+  }
 
   emit studySaved();
 }
@@ -2260,6 +2277,7 @@ void LightApp_Application::onStudySaved( SUIT_Study* s )
 /*!Protected SLOT. On study closed.*/
 void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ )
 {
+  DBG_FUN();
   /*
   disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
               this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
@@ -2288,6 +2306,7 @@ void LightApp_Application::onDesktopActivated()
 
 void LightApp_Application::studyOpened( SUIT_Study* s )
 {
+  DBG_FUN();
   CAM_Application::studyOpened( s );
 
   updateWindows();
@@ -2296,6 +2315,7 @@ void LightApp_Application::studyOpened( SUIT_Study* s )
 
 void LightApp_Application::studySaved( SUIT_Study* s )
 {
+  DBG_FUN();
   CAM_Application::studyOpened( s );
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
   if ( aResMgr && activeStudy() ) {
@@ -4971,6 +4991,8 @@ void LightApp_Application::onWCDestroyed( QObject* ob )
 
 void LightApp_Application::onMRUActivated( const QString& name )
 {
+  DBG_FUN();
+  ARG(name);
   SUIT_Session* s = SUIT_Session::session();
   if ( s && s->activeApplication() == this )
     onOpenDoc( name );
index 2729b4d5a94e4cb346c7269463875112542e3844..e057671aac23cc9d08eea90ed24674ddf883831b 100644 (file)
 #include <SUIT_DataBrowser.h>
 #include <SUIT_DataObject.h>
 
+//---------------------------------------------------------
+#define USE_DEBUG
+//#define MB_IGNORE_QT
+//#define MB_FULL_DUMP
+#define MBCLASSNAME "LightApp_DataModel"
+#include "MBDebug.h"
+// <-- insert includes for addtional debug headers here!
+//---------------------------------------------------------
+
 /*!
   Constructor
 */
 LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule )
 : CAM_DataModel( theModule )
 {
+  DBG_FUN();
   myGroupId = 0;
   if( module() )
         myGroupId = qHash( module()->name() );
@@ -50,6 +60,7 @@ LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule )
 */
 LightApp_DataModel::~LightApp_DataModel()
 {
+  DBG_FUN();
 }
 
 /*!
@@ -57,6 +68,7 @@ LightApp_DataModel::~LightApp_DataModel()
 */
 bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList )
 {
+  DBG_FUN();
   emit opened(); //TODO: is it really needed? to be removed maybe...
   return true;
 }
@@ -66,6 +78,7 @@ bool LightApp_DataModel::open( const QString&, CAM_Study*, QStringList )
 */
 bool LightApp_DataModel::save( QStringList& )
 {
+  DBG_FUN();
   emit saved();
   return true;
 }
@@ -73,9 +86,12 @@ bool LightApp_DataModel::save( QStringList& )
 /*!
   Emit saved()
 */
-bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList& )
+bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList&, bool isBackup/*=false*/ )
 {
-  emit saved();
+  DBG_FUN();
+  ARG(isBackup);
+  if (!isBackup)
+    emit saved();
   return true;
 }
 
@@ -93,6 +109,7 @@ bool LightApp_DataModel::dumpPython( const QString&, CAM_Study*, bool, QStringLi
 */
 bool LightApp_DataModel::close()
 {
+  DBG_FUN();
   emit closed();
   return true;
 }
@@ -119,6 +136,7 @@ void LightApp_DataModel::updateWidgets()
 */
 void LightApp_DataModel::update( LightApp_DataObject*, LightApp_Study* )
 {
+  DBG_FUN();
   // san: Previously modelRoot was casted to LightApp_ModuleObject*,
   // BUT this is incorrect: in full SALOME the model root has different type.
   // Hopefully LightApp_DataObject* is sufficient here.
index 98f9d71aa574965f5518af6dc6ec8b5d97b5221d..23d2c29e65a74eb81fce504abe1e38258a052d73 100644 (file)
@@ -53,7 +53,7 @@ public:
 
   virtual bool                        open( const QString&, CAM_Study*, QStringList );
   virtual bool                        save( QStringList& );
-  virtual bool                        saveAs( const QString&, CAM_Study*, QStringList& );
+  virtual bool                        saveAs( const QString&, CAM_Study*, QStringList&, bool isBackup=false );
   virtual bool                        close();
   virtual bool                        dumpPython( const QString&,
                                                  CAM_Study*,
index 222b2ae04f35963dddc4b77aa29f66274369864d..b08fd5d3e06beb19440786eac1ff8da25e625d13 100644 (file)
 
 #include <set>
 
+//---------------------------------------------------------
+#define USE_DEBUG
+//#define MB_IGNORE_QT
+//#define MB_FULL_DUMP
+#define MBCLASSNAME "LightApp_Study"
+#include "MBDebug.h"
+// <-- insert includes for addtional debug headers here!
+//---------------------------------------------------------
+
 /*!
   Constructor.
 */
 LightApp_Study::LightApp_Study( SUIT_Application* app )
 : CAM_Study( app )
 {
+  DBG_FUN();
   // HDF persistence
   myDriver = new LightApp_HDFDriver();
   //myDriver = new LightApp_Driver();
@@ -52,6 +62,7 @@ LightApp_Study::LightApp_Study( SUIT_Application* app )
 */
 LightApp_Study::~LightApp_Study()
 {
+  DBG_FUN();
   delete myDriver; myDriver = 0;
 }
 
@@ -60,6 +71,8 @@ LightApp_Study::~LightApp_Study()
 */
 bool LightApp_Study::createDocument( const QString& theStr )
 {
+  DBG_FUN();
+  ARG(theStr);
   // create myRoot
   setRoot( new LightApp_RootObject( this ) );
 
@@ -75,6 +88,8 @@ bool LightApp_Study::createDocument( const QString& theStr )
 */
 bool LightApp_Study::openDocument( const QString& theFileName )
 {
+  DBG_FUN();
+  ARG(theFileName);
   myDriver->ClearDriverContents();
   // create files for models from theFileName
   if( !openStudyData(theFileName, 0)) // 0 means persistence file
@@ -104,6 +119,8 @@ bool LightApp_Study::openDocument( const QString& theFileName )
 */
 bool LightApp_Study::loadDocument( const QString& theStudyName )
 {
+  DBG_FUN();
+  ARG(theStudyName);
   myDriver->ClearDriverContents();
   if( !openStudyData(theStudyName, 0)) // 0 means persistence file
     return false;
@@ -134,8 +151,11 @@ bool LightApp_Study::loadDocument( const QString& theStudyName )
 /*!
   Saves document
 */
-bool LightApp_Study::saveDocumentAs( const QString& theFileName )
+bool LightApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/*=false*/ )
 {
+  DBG_FUN();
+  ARG(theFileName);
+  ARG(isBackup);
   SUIT_ResourceMgr* resMgr = application()->resourceMgr();
   if( !resMgr )
     return false;
@@ -190,7 +210,7 @@ bool LightApp_Study::saveDocumentAs( const QString& theFileName )
   bool res = saveStudyData(theFileName, 0); // 0 means persistence file
   res = res && CAM_Study::saveDocumentAs( theFileName );
   //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
-  if ( res )
+  if ( res && !isBackup)
     emit saved( this );
 
   return res;
@@ -201,6 +221,7 @@ bool LightApp_Study::saveDocumentAs( const QString& theFileName )
 */
 bool LightApp_Study::saveDocument()
 {
+  DBG_FUN();
   ModelList list; dataModels( list );
 
   myDriver->ClearDriverContents();
@@ -229,6 +250,8 @@ bool LightApp_Study::saveDocument()
 */
 void LightApp_Study::closeDocument(bool permanently)
 {
+  DBG_FUN();
+  ARG(permanently);
   // Inform everybody that this study is going to close when it's most safe to,
   // i.e. in the very beginning
   emit closed( this );
@@ -328,6 +351,10 @@ void LightApp_Study::addComponent(const CAM_DataModel* /*dm*/)
 */
 void LightApp_Study::saveModuleData(QString theModuleName, int type, QStringList theListOfFiles)
 {
+  DBG_FUN();
+  ARG(theModuleName);
+  ARG(type);
+  ARG(theListOfFiles);
   int aNb = theListOfFiles.count();
   if ( aNb == 0 )
     return;
@@ -364,6 +391,8 @@ void LightApp_Study::openModuleData(QString theModuleName, int /*type*/, QString
 */
 bool LightApp_Study::saveStudyData( const QString& theFileName, int /*type*/ )
 {
+  DBG_FUN();
+  ARG(theFileName);
   ModelList list; dataModels( list );
   SUIT_ResourceMgr* resMgr = application()->resourceMgr();
   if( !resMgr )
index 1569d467dac758434a3a24c631181d1b04895d51..d3a5ca953951f4683537b356afcf30fd6d4423cf 100644 (file)
@@ -76,10 +76,12 @@ public:
   virtual bool        loadDocument( const QString& ); 
 
   virtual bool        saveDocument();
-  virtual bool        saveDocumentAs( const QString& );
+  virtual bool        saveDocumentAs( const QString& , bool isBackup=false );
 
   virtual void        closeDocument(bool permanently = true);
 
+  virtual bool        dump( const QString&, bool, bool, bool ) { return false; }
+
   virtual bool        isSaved()  const;
   virtual bool        isModified() const;
 
index 054287882ddacfd0d199e3413428878e710f55ea..b1009a50170aa2a669d0ee499c02204dbc584c53 100644 (file)
 #include "SUIT_MessageBox.h"
 #include "SUIT_Application.h"
 
+//---------------------------------------------------------
+#define USE_DEBUG
+//#define MB_IGNORE_QT
+//#define MB_FULL_DUMP
+#define MBCLASSNAME "SUIT_Study"
+#include "MBDebug.h"
+// <-- insert includes for addtional debug headers here!
+//---------------------------------------------------------
+
 /*!\class SUIT_Study
  * Support study management. Object management. Operation management.
  */
@@ -41,9 +50,11 @@ myIsSaved( false ),
 myIsModified( false ),
 myBlockChangeState( false )
 {
+  DBG_FUN();
   static int _id = 0;
 
   myId = ++_id;
+  SHOW(myId);
 
   myRoot = new SUIT_DataObject();
 }
@@ -51,6 +62,7 @@ myBlockChangeState( false )
 /*!Destructor.*/
 SUIT_Study::~SUIT_Study()
 {
+  DBG_FUN();
   delete myRoot;
   myRoot = 0;
 }
@@ -142,11 +154,19 @@ bool SUIT_Study::openDocument( const QString& fileName )
 /*!
  * Save document as \a fileName. Set file name.
  */
-bool SUIT_Study::saveDocumentAs( const QString& fileName )
-{
-  myName = fileName;
-  myIsSaved = true;
-  myIsModified = false;
+bool SUIT_Study::saveDocumentAs( const QString& fileName, bool isBackup/*=false*/ )
+{
+  DBG_FUN();
+  ARG(fileName);
+  ARG(isBackup);
+  if (!isBackup) {
+    myName = fileName;
+    myIsSaved = true;
+    myIsModified = false;
+  }
+  SHOW(myName);
+  SHOW(myIsSaved);
+  SHOW(myIsModified);
 
   return true;
 }
@@ -156,6 +176,7 @@ bool SUIT_Study::saveDocumentAs( const QString& fileName )
  */
 bool SUIT_Study::saveDocument()
 {
+  DBG_FUN();
   return saveDocumentAs( myName );
 }
 
index 5ea1ad479c43c1e05b475f7d9839d09f51ecf411..b61821ab9eec0cf85e371de7fc4a96ebaed4df61 100644 (file)
@@ -60,7 +60,7 @@ public:
   virtual bool      createDocument( const QString& );
 
   bool              saveDocument();
-  virtual bool      saveDocumentAs( const QString& );
+  virtual bool      saveDocumentAs( const QString& , bool isBackup=false );
 
   virtual void      update();
 
index 96aa82adca7e9e15e3693b4113cf6214bfa08c95..6d97460513d09610720625cf81714964b819b9fb 100644 (file)
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOME_Exception)
 
+//---------------------------------------------------------
+#define USE_DEBUG
+//#define MB_IGNORE_QT
+//#define MB_FULL_DUMP
+#define MBCLASSNAME "SalomeApp_Study"
+#include "MBDebug.h"
+// <-- insert includes for addtional debug headers here!
+//---------------------------------------------------------
+
 //#define NOTIFY_BY_EVENT
 
 class ObserverEvent : public QEvent
@@ -391,6 +400,7 @@ private:
 SalomeApp_Study::SalomeApp_Study( SUIT_Application* app )
 : LightApp_Study( app ), myObserver( 0 )
 {
+  DBG_FUN();
   myStudyDS = SalomeApp_Application::getStudy();
 }
 
@@ -399,6 +409,7 @@ SalomeApp_Study::SalomeApp_Study( SUIT_Application* app )
 */
 SalomeApp_Study::~SalomeApp_Study()
 {
+  DBG_FUN();
   if ( myObserver ) {
     PortableServer::ObjectId_var oid = myObserver->_default_POA()->servant_to_id( myObserver );
     myObserver->_default_POA()->deactivate_object( oid.in() );
@@ -447,6 +458,8 @@ _PTR(Study) SalomeApp_Study::studyDS() const
 */
 bool SalomeApp_Study::createDocument( const QString& theStr )
 {
+  DBG_FUN();
+  ARG(theStr);
   MESSAGE( "createDocument" );
 
   setStudyName( QString::fromUtf8(myStudyDS->URL().c_str()) );
@@ -477,6 +490,8 @@ bool SalomeApp_Study::createDocument( const QString& theStr )
 */
 bool SalomeApp_Study::openDocument( const QString& theFileName )
 {
+  DBG_FUN();
+  ARG(theFileName);
   MESSAGE( "openDocument" );
 
   // read HDF file
@@ -547,6 +562,8 @@ bool SalomeApp_Study::openDocument( const QString& theFileName )
 */
 bool SalomeApp_Study::loadDocument( const QString& theStudyName )
 {
+  DBG_FUN();
+  ARG(theStudyName);
   MESSAGE( "loadDocument" );
 
   setRoot( new SalomeApp_RootObject( this ) ); // create myRoot
@@ -595,10 +612,14 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName )
   Saves document
   \param theFileName - name of file
 */
-bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
+bool SalomeApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/*=false*/ )
 {
+  DBG_FUN();
+  ARG(theFileName);
+  ARG(isBackup);
+
   bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", false );
-  if ( store )
+  if ( store && !isBackup )
     SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
 
   ModelList list; dataModels( list );
@@ -611,7 +632,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
     if ( LightApp_DataModel* aModel = 
          dynamic_cast<LightApp_DataModel*>( it.next() ) ) {
       listOfFiles.clear();
-      aModel->saveAs( theFileName, this, listOfFiles );
+      aModel->saveAs( theFileName, this, listOfFiles, isBackup );
       if ( !listOfFiles.isEmpty() )
         saveModuleData(aModel->module()->name(), 0, // 0 means persistence file
                        listOfFiles);
@@ -630,7 +651,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
 
   res = res && saveStudyData(theFileName, 0); // 0 means persistence file
 
-  if ( res )
+  if ( res && !isBackup)
     emit saved( this );
 
   return res;
@@ -641,6 +662,7 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName )
 */
 bool SalomeApp_Study::saveDocument()
 {
+  DBG_FUN();
   bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
   if ( store )
     SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
@@ -683,6 +705,7 @@ bool SalomeApp_Study::saveDocument()
 */
 void SalomeApp_Study::closeDocument(bool permanently)
 {
+  DBG_FUN();
   LightApp_Study::closeDocument(permanently);
 
   // close SALOMEDS document
@@ -721,6 +744,11 @@ bool SalomeApp_Study::dump( const QString& theFileName,
                             bool isMultiFile,
                             bool toSaveGUI )
 {
+  DBG_FUN();
+  ARG(theFileName);
+  ARG(toPublish);
+  ARG(isMultiFile);
+  ARG(toSaveGUI);
   int savePoint = 0;
   _PTR(AttributeParameter) ap;
   _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
index 38c6c0012a5540c96f268323ac25981841990c66..9f1bb755619acf073820455a5e6ac0151e71e05c 100644 (file)
@@ -50,7 +50,7 @@ public:
   virtual bool        loadDocument( const QString& );
 
   virtual bool        saveDocument();
-  virtual bool        saveDocumentAs( const QString& );
+  virtual bool        saveDocumentAs( const QString& , bool isBackup=false );
 
   virtual void        closeDocument(bool permanently = true);