[vlmc-devel] commit: ProjectManager: Don't overwrite the project file when autosaving. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Tue Jun 1 00:35:29 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Jun  1 00:38:04 2010 +0200| [10326928e38487a5ef7b16577505a2ffe5c44ae9] | committer: Hugo Beauzée-Luyssen 

ProjectManager: Don't overwrite the project file when autosaving.

Fixes #88

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=10326928e38487a5ef7b16577505a2ffe5c44ae9
---

 src/Gui/project/GuiProjectManager.cpp |   12 +++++++++---
 src/Gui/project/GuiProjectManager.h   |    4 ++++
 src/Project/ProjectManager.cpp        |   10 ++++++++--
 src/Project/ProjectManager.h          |    3 ++-
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index ce8be7f..cb99b84 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -122,13 +122,13 @@ GUIProjectManager::createNewProjectFile( bool saveAs )
 }
 
 void
-GUIProjectManager::saveProject( bool saveAs /*= true*/ )
+GUIProjectManager::saveProject( bool saveAs /* = false */ )
 {
     //If the project is still unsaved, or if we want to
     //save the project with a new name
     if ( createNewProjectFile( saveAs ) == false )
         return ;
-    ProjectManager::saveProject( saveAs );
+    ProjectManager::saveProject( outputFileName() );
 }
 
 bool
@@ -154,7 +154,7 @@ GUIProjectManager::autoSaveRequired()
 {
     if ( m_projectFile == NULL )
         return ;
-    saveProject( false );
+    ProjectManager::__saveProject( createAutoSaveOutputFileName() );
 }
 
 void
@@ -219,3 +219,9 @@ GUIProjectManager::loadTimeline( const QDomElement &root )
 {
     Timeline::getInstance()->load( root );
 }
+
+QString
+GUIProjectManager::createAutoSaveOutputFileName() const
+{
+    return m_projectFile->fileName() + "~";
+}
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index eefa185..e24c113 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -42,6 +42,9 @@ public:
      *  \return     The project to load.
      */
     QString         acquireProjectFileName();
+    /**
+     *  \brief      Save the project using the current project file.
+     */
     void            saveProject( bool saveAs = false );
     /**
      *  \brief      Ask the project manager to close current project.
@@ -60,6 +63,7 @@ protected:
 
 private:
     bool            createNewProjectFile( bool saveAs );
+    QString         createAutoSaveOutputFileName() const;
 
 private:
     QTimer*         m_timer;
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index 329baec..cae08cf 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -223,9 +223,9 @@ ProjectManager::closeProject()
 }
 
 void
-ProjectManager::saveProject( bool )
+ProjectManager::saveProject( const QString &outputFileName )
 {
-    __saveProject( m_projectFile->fileName() );
+    __saveProject( outputFileName );
     emit projectSaved();
     emit projectUpdated( projectName(), true );
 }
@@ -251,3 +251,9 @@ ProjectManager::failedToLoad( const QString &reason ) const
     qCritical() << tr( "Failed to load the project file: %1. Aborting." ).arg( reason );
     abort();
 }
+
+QString
+ProjectManager::outputFileName() const
+{
+    return m_projectFile->fileName();
+}
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index f4d44da..b0e6d4e 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -49,7 +49,7 @@ public:
     void            loadProject( const QString& fileName );
     QStringList     recentsProjects() const;
     virtual bool    closeProject();
-    virtual void    saveProject( bool saveAs = false );
+    virtual void    saveProject( const QString &outputFileName );
     bool            loadEmergencyBackup();
     void            emergencyBackup();
 
@@ -76,6 +76,7 @@ protected:
      *  \return     The project name.
      */
     QString         projectName() const;
+    virtual QString outputFileName() const;
 
     virtual void    failedToLoad( const QString& reason ) const;
     virtual void    loadTimeline( const QDomElement& ){};



More information about the Vlmc-devel mailing list