[vlmc-devel] Avoid invoking Project::getInstance() while constructing the instance
Hugo Beauzée-Luyssen
git at videolan.org
Sat Mar 29 01:03:40 CET 2014
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Sat Mar 29 01:37:40 2014 +0200| [bb2303bc9499a06a67fbcb51a86a1fbda8fec30b] | committer: Hugo Beauzée-Luyssen
Avoid invoking Project::getInstance() while constructing the instance
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=bb2303bc9499a06a67fbcb51a86a1fbda8fec30b
---
src/Library/Library.cpp | 7 ++++++-
src/Library/Library.h | 3 ++-
src/Main/Project.cpp | 8 ++++----
src/Project/ProjectManager.cpp | 5 -----
src/Project/ProjectManager.h | 9 +++------
src/Workflow/MainWorkflow.cpp | 4 +++-
src/Workflow/MainWorkflow.h | 3 ++-
7 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index 5f7faba..879fd58 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -31,6 +31,7 @@
#include "Media/Clip.h"
#include "Media/Media.h"
#include "Metadata/MetaDataManager.h"
+#include "Project/ProjectManager.h"
#include "Settings/Settings.h"
#include "Tools/VlmcDebug.h"
#include "Project/Workspace.h"
@@ -39,10 +40,14 @@
#include <QHash>
#include <QUuid>
-Library::Library( Workspace *workspace )
+Library::Library( Workspace *workspace , ProjectManager *projectManager )
: m_cleanState( true )
, m_workspace( workspace )
{
+ connect( projectManager, SIGNAL( projectClosed() ),
+ this, SLOT( clear() ) );
+ connect( projectManager, SIGNAL( cleanStateChanged( bool ) ),
+ this, SLOT( cleanChanged( bool ) ) );
}
void
diff --git a/src/Library/Library.h b/src/Library/Library.h
index a60821a..c75fb0a 100644
--- a/src/Library/Library.h
+++ b/src/Library/Library.h
@@ -39,6 +39,7 @@ class QDomElement;
class Clip;
class Media;
+class ProjectManager;
class Workspace;
/**
@@ -51,7 +52,7 @@ class Library : public MediaContainer
Q_DISABLE_COPY( Library );
public:
- Library( Workspace* workspace );
+ Library( Workspace* workspace, ProjectManager* projectManager );
virtual ~Library(){}
virtual void addMedia( Media* media );
virtual Media *addMedia( const QFileInfo &fileInfo );
diff --git a/src/Main/Project.cpp b/src/Main/Project.cpp
index bdfd1ad..802098f 100644
--- a/src/Main/Project.cpp
+++ b/src/Main/Project.cpp
@@ -32,22 +32,22 @@
Project::Project()
{
+ m_projectManager = new ProjectManager;
m_settings = new Settings( QString() );
m_undoStack = new QUndoStack;
- m_workflow = new MainWorkflow;
+ m_workflow = new MainWorkflow( m_projectManager );
m_workspace = new Workspace( m_settings );
- m_library = new Library( m_workspace );
- m_projectManager = new ProjectManager;
+ m_library = new Library( m_workspace, m_projectManager );
}
Project::~Project()
{
- delete m_projectManager;
delete m_library;
delete m_workspace;
delete m_workflow;
delete m_undoStack;
delete m_settings;
+ delete m_projectManager;
}
Library*
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index 33ec513..334dfa6 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -53,11 +53,6 @@ ProjectManager::ProjectManager()
: m_projectFile( NULL )
, m_needSave( false )
{
- connect( this, SIGNAL( projectClosed() ), Project::getInstance()->library(), SLOT( clear() ) );
- connect( this, SIGNAL( projectClosed() ), Project::getInstance()->workflow(), SLOT( clear() ) );
- connect( Project::getInstance()->library(), SIGNAL( cleanStateChanged( bool ) ),
- this, SLOT( cleanChanged( bool ) ) );
-
m_recentsProjects = VLMC_GET_STRINGLIST( SETTINGS_RECENTS );
//If the variable was empty, it will return a list with one empty string in it.
m_recentsProjects.removeAll( "" );
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index c1b056d..8d48e7a 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -26,17 +26,14 @@
#include "config.h"
class QTimer;
+class QFile;
+class QDomDocument;
+class QXmlStreamWriter;
#include <QObject>
#include <QStringList>
#include <QDomElement>
-#include "Tools/Singleton.hpp"
-
-class QFile;
-class QDomDocument;
-class QXmlStreamWriter;
-
class IProjectManagerUiCb
{
public:
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index b2589e8..2dd11c3 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -28,6 +28,7 @@
#include "ClipWorkflow.h"
#include "Library/Library.h"
#include "MainWorkflow.h"
+#include "Project/ProjectManager.h"
#include "TrackWorkflow.h"
#include "TrackHandler.h"
#include "Settings/Settings.h"
@@ -37,7 +38,7 @@
#include <QDomElement>
#include <QMutex>
-MainWorkflow::MainWorkflow( int trackCount ) :
+MainWorkflow::MainWorkflow( ProjectManager *projectManager, int trackCount ) :
m_blackOutput( NULL ),
m_lengthFrame( 0 ),
m_renderStarted( false ),
@@ -59,6 +60,7 @@ MainWorkflow::MainWorkflow( int trackCount ) :
this, SLOT( lengthUpdated( qint64 ) ) );
m_currentFrame[i] = 0;
}
+ connect( projectManager, SIGNAL( projectClosed() ), this, SLOT( clear() ) );
}
MainWorkflow::~MainWorkflow()
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 941dc1d..6913ecd 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -32,6 +32,7 @@ class Clip;
class ClipHelper;
class EffectsEngine;
class Effect;
+class ProjectManager;
class TrackHandler;
class TrackWorkflow;
namespace Workflow
@@ -56,7 +57,7 @@ class MainWorkflow : public QObject
Q_OBJECT
public:
- MainWorkflow( int trackCount = 64 );
+ MainWorkflow( ProjectManager* projectManager, int trackCount = 64 );
~MainWorkflow();
/**
More information about the Vlmc-devel
mailing list