[vlmc-devel] [PATCH 1/3] backup when vlmc closes unexpectedly

Sanket Markan sanketmarkan at gmail.com
Sat Mar 12 18:32:39 CET 2016


---
 src/Gui/MainWindow.cpp  | 18 +++++++++++++++---
 src/Gui/MainWindow.h    |  1 +
 src/Main/main.cpp       |  2 +-
 src/Project/Project.cpp |  1 +
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index fc88afd..041d6ca 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -126,9 +126,13 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
     connect( m_mediaLibrary, SIGNAL( importRequired() ),
              this, SLOT( on_actionImport_triggered() ) );
 
+    project = false;
 #ifdef WITH_CRASHHANDLER
     if ( restoreSession() == true )
+    {
+        project = true;
         return ;
+    }
 #endif
     // Restore the geometry
     restoreGeometry( VLMC_GET_BYTEARRAY( "private/MainWindowGeometry" ) );
@@ -855,9 +859,17 @@ MainWindow::restoreSession()
                                QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
         if ( res == QMessageBox::Yes )
         {
-            //FIXME: We need a setting with the latest project file & restore the project.
-            QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) );
-        }
+            QFile* backupFile = Core::getInstance()->project()->emergencyBackupFile();
+            if ( backupFile == NULL )
+            {
+              QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) );
+            }
+            else
+            {
+              Core::getInstance()->loadProject( backupFile->fileName() );
+              ret = true;
+            }
+      }
     }
     Core::getInstance()->settings()->setValue( "private/CleanQuit", true );
     return ret;
diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h
index 8f7d4bc..a17bfd3 100644
--- a/src/Gui/MainWindow.h
+++ b/src/Gui/MainWindow.h
@@ -62,6 +62,7 @@ public:
 
     void registerWidgetInWindowMenu( QDockWidget* widget );
     void        showWizard();
+    bool project;
 
 public slots:
     void        zoomIn();
diff --git a/src/Main/main.cpp b/src/Main/main.cpp
index f2e9b49..5316606 100644
--- a/src/Main/main.cpp
+++ b/src/Main/main.cpp
@@ -158,7 +158,7 @@ VLMCGuimain( int argc, char **argv )
     }
 
     //Don't show the wizard if a project has been passed through command line.
-    if ( project == false )
+    if ( project == false && w.project == false)
         w.showWizard();
 
     /* Main Window display */
diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index 0401154..97c5a65 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -326,6 +326,7 @@ Project::autoSaveRequired()
     if ( m_projectFile == NULL )
         return ;
     saveProject( m_projectFile->fileName() + Project::backupSuffix );
+    emergencyBackup();
 }
 
 
-- 
1.9.1



More information about the Vlmc-devel mailing list