[vlmc-devel] Move Backend creation from MainWindow to Main

Jean-Baptiste Kempf git at videolan.org
Sun Mar 2 16:27:58 CET 2014


vlmc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Mar  2 16:27:08 2014 +0100| [8832573dc30ea1e4c8408f5427801456e88220ea] | committer: Jean-Baptiste Kempf

Move Backend creation from MainWindow to Main

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

 src/Gui/MainWindow.cpp |    5 ++---
 src/Gui/MainWindow.h   |    3 ++-
 src/Main/main.cpp      |   29 ++++++++++++++++++-----------
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 63580fd..eabc303 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -68,8 +68,8 @@
 #include "Settings/SettingsManager.h"
 #include "LanguageHelper.h"
 
-MainWindow::MainWindow( QWidget *parent ) :
-    QMainWindow( parent ), m_fileRenderer( NULL )
+MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent ) :
+    QMainWindow( parent ), m_backend( backend ), m_fileRenderer( NULL )
 {
     m_ui.setupUi( this );
 
@@ -440,7 +440,6 @@ MainWindow::createStatusBar()
 void
 MainWindow::initializeDockWidgets()
 {
-    m_backend = Backend::getBackend();
     m_renderer = new WorkflowRenderer( m_backend );
     m_renderer->initializeRenderer();
     m_timeline = new Timeline( m_renderer, this );
diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h
index c68de8a..8c4c8f6 100644
--- a/src/Gui/MainWindow.h
+++ b/src/Gui/MainWindow.h
@@ -53,7 +53,8 @@ class MainWindow : public QMainWindow
     Q_DISABLE_COPY( MainWindow )
 
 public:
-    explicit MainWindow( QWidget *parent = 0 );
+    explicit MainWindow( Backend::IBackend* backend,
+                         QWidget *parent = 0 );
     ~MainWindow();
 
     void registerWidgetInWindowMenu( QDockWidget* widget );
diff --git a/src/Main/main.cpp b/src/Main/main.cpp
index f2c60af..e804469 100644
--- a/src/Main/main.cpp
+++ b/src/Main/main.cpp
@@ -27,16 +27,17 @@
  */
 
 #include "config.h"
-#include "MainWindow.h"
-#include "IntroDialog.h"
-#include "LanguageHelper.h"
-#include "Workflow/Types.h"
+
 #include "Tools/VlmcDebug.h"
+#include "Workflow/Types.h"
 #include "Renderer/ConsoleRenderer.h"
-#include "Renderer/WorkflowFileRenderer.h"
-
-#include "project/GuiProjectManager.h"
 #include "Project/ProjectManager.h"
+#include "Backend/IBackend.h"
+
+#include "Gui/MainWindow.h"
+#include "Gui/IntroDialog.h"
+#include "Gui/LanguageHelper.h"
+#include "Gui/project/GuiProjectManager.h"
 
 #include <QApplication>
 #include <QColor>
@@ -50,7 +51,7 @@
 #endif
 
 static void
-VLMCmainCommon( const QCoreApplication &app )
+VLMCmainCommon( const QCoreApplication &app, Backend::IBackend** backend )
 {
     app.setApplicationName( "vlmc" );
     app.setOrganizationName( "VideoLAN" );
@@ -63,6 +64,8 @@ VLMCmainCommon( const QCoreApplication &app )
     qRegisterMetaType<Vlmc::FrameChangedReason>( "Vlmc::FrameChangedReason" );
     qRegisterMetaType<QVariant>( "QVariant" );
     qRegisterMetaType<QUuid>( "QUuid" );
+
+    *backend = Backend::getBackend();
 }
 
 /**
@@ -79,7 +82,9 @@ VLMCGuimain( int argc, char **argv )
     XInitThreads();
 #endif
     QApplication app( argc, argv );
-    VLMCmainCommon( app );
+
+    Backend::IBackend* backend;
+    VLMCmainCommon( app, &backend );
 
     /* Load a project file */
     bool        project = false;
@@ -140,7 +145,7 @@ VLMCGuimain( int argc, char **argv )
     d.exec();
 #endif
 
-    MainWindow w;
+    MainWindow w( backend );
 
     //Don't show the wizard if a project has been passed through command line.
     if ( project == false )
@@ -162,7 +167,9 @@ int
 VLMCCoremain( int argc, char **argv )
 {
     QCoreApplication app( argc, argv );
-    VLMCmainCommon( app );
+
+    Backend::IBackend* backend;
+    VLMCmainCommon( app, &backend );
 
     /* Load a project file */
     if ( app.arguments().count() < 3 )



More information about the Vlmc-devel mailing list