[vlc-devel] [PATCH 3/3] Qt: use singleton template

Francois Cartegnie fcvlcdev at free.fr
Wed Mar 3 21:51:12 CET 2010


---
 modules/gui/qt4/input_manager.cpp |    1 -
 modules/gui/qt4/input_manager.hpp |   18 +++---------------
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index b589564..3742e9e 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -897,7 +897,6 @@ void InputManager::AtoBLoop( float, int64_t i_time, int )
  * take care of updating the main playlist input.
  * Used in the main playlist Dialog
  **********************************************************************/
-MainInputManager * MainInputManager::instance = NULL;
 
 MainInputManager::MainInputManager( intf_thread_t *_p_intf )
                  : QObject(NULL), p_intf( _p_intf )
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index d96c0a0..29f1837 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -32,6 +32,7 @@
 #include <vlc_input.h>
 
 #include "qt4.hpp"
+#include "util/singleton.hpp"
 
 #include <QObject>
 #include <QEvent>
@@ -236,22 +237,11 @@ signals:
     void encryptionChanged( bool );
 };
 
-class MainInputManager : public QObject
+class MainInputManager : public QObject, public Singleton< MainInputManager >
 {
+    friend class Singleton< MainInputManager >;
     Q_OBJECT;
 public:
-    static MainInputManager *getInstance( intf_thread_t *_p_intf )
-    {
-        if( !instance )
-            instance = new MainInputManager( _p_intf );
-        return instance;
-    }
-    static void killInstance()
-    {
-        delete instance;
-        instance = NULL;
-    }
-
     input_thread_t *getInput() { return p_input; }
     InputManager *getIM() { return im; }
     inline input_item_t *currentInputItem()
@@ -266,8 +256,6 @@ private:
     MainInputManager( intf_thread_t * );
     virtual ~MainInputManager();
 
-    static MainInputManager *instance;
-
     void customEvent( QEvent * );
 
     InputManager            *im;
-- 
1.6.4.4




More information about the vlc-devel mailing list