Commit 528e9be1 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Releasing VLCInstance at exit (thus solving a big memory leak)

Cleaned code.
parent 9ca5a010
......@@ -79,7 +79,7 @@ MainWindow::~MainWindow()
if ( m_renderer )
delete m_renderer;
MetaDataManager::destroyInstance();
LibVLCpp::Instance::kill();
LibVLCpp::Instance::destroyInstance();
}
void MainWindow::changeEvent( QEvent *e )
......
......@@ -26,13 +26,11 @@
using namespace LibVLCpp;
Instance* Instance::m_singleton = NULL;
Instance::Instance()
{
char const *argv[] =
{
// "-vvvvv",
"-vvvvv",
"--no-skip-frames",
// "--intf", "dummy",
"--text-renderer", "dummy",
......@@ -47,8 +45,7 @@ Instance::Instance()
CheckVlcppException(m_ex);
}
Instance::Instance( int argc, const char** argv )
Instance::~Instance()
{
m_internalPtr = libvlc_new( argc, argv, m_ex );
CheckVlcppException(m_ex);
libvlc_release( m_internalPtr );
}
......@@ -26,37 +26,22 @@
#include "vlc/vlc.h"
#include "VLCpp.hpp"
#include "VLCException.h"
#include "Singleton.hpp"
namespace LibVLCpp
{
class Instance : public Internal< libvlc_instance_t >
class Instance : public Internal< libvlc_instance_t >,
public Singleton<Instance>
{
private:
Instance();
Instance( int argc, const char** argv );
~Instance();
private:
Exception m_ex;
static Instance* m_singleton;
public:
static Instance* getInstance()
{
if (NULL == m_singleton)
m_singleton = new Instance();
return m_singleton;
}
static void kill()
{
if ( m_singleton != NULL )
{
delete m_singleton;
m_singleton = NULL;
}
}
friend class Singleton<Instance>;
};
}
......
......@@ -41,6 +41,7 @@ namespace LibVLCpp
operator T*() { return m_internalPtr; }
protected:
Internal() : m_internalPtr( NULL ) {}
~Internal(){}
T* m_internalPtr;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment