[vlmc-devel] [PATCH 3/3] Clear Library and MainWorkflow when a project is closed

Yikai Lu luyikei.qmltu at gmail.com
Sun Apr 10 11:39:42 CEST 2016


Clearing only in postLoad causes a problem when a new project is created, which will call save() first.
---
 src/Library/Library.cpp       | 1 -
 src/Main/Core.cpp             | 2 ++
 src/Workflow/MainWorkflow.cpp | 1 -
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index 747ef42..555d860 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -69,7 +69,6 @@ Library::preSave()
 void
 Library::postLoad()
 {
-    clear();
     for ( const auto& var : m_settings->value( "medias" )->get().toList() )
         createMediaFromVariant( var );
 
diff --git a/src/Main/Core.cpp b/src/Main/Core.cpp
index c12fc7a..7ec4c8b 100644
--- a/src/Main/Core.cpp
+++ b/src/Main/Core.cpp
@@ -60,6 +60,8 @@ Core::Core()
     connect( m_library, &Library::cleanStateChanged, m_currentProject, &Project::libraryCleanChanged );
     connect( m_currentProject, SIGNAL( projectLoaded( QString, QString ) ),
              m_recentProjects, SLOT( projectLoaded( QString, QString ) ) );
+    connect( m_currentProject, &Project::projectClosed, m_library, &Library::clear );
+    connect( m_currentProject, &Project::projectClosed, m_workflow, &MainWorkflow::clear );
 
     m_timer.start();
 }
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index f144353..264982b 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -337,7 +337,6 @@ MainWorkflow::preSave()
 void
 MainWorkflow::postLoad()
 {
-    clear();
     QVariantList l = m_settings->value( "tracks" )->get().toList();
     for ( unsigned int i = 0; i < Workflow::NbTrackType; ++i )
         m_tracks[i]->loadFromVariant( l[i] );
-- 
1.9.1



More information about the Vlmc-devel mailing list