Commit fc822ead authored by Christophe Courtaut's avatar Christophe Courtaut
Browse files

Fixed memleaks in snapshot

parent a9f9f9dc
......@@ -26,7 +26,7 @@
#include "InputMedia.h"
InputMedia::InputMedia( const QString& mrl, LibVLCpp::Instance* instance /*= NULL*/ ) :
Media( instance, mrl ), m_snapshot( NULL ), m_pixelBuffer( NULL ), m_image ( NULL )
Media( instance, mrl ), m_pixelBuffer( NULL ), m_image ( NULL )
{
// m_vlcMedia->outputInVmem();
// m_vlcMedia->setLockCallback( InputMedia::lock );
......@@ -74,8 +74,6 @@ void InputMedia::unlock( LibVLCpp::Media::DataCtx* ctx )
QPixmap* InputMedia::takeSnapshot( unsigned int width, unsigned int height )
{
if ( m_snapshot == NULL )
{
// qint64 currentTime = m_vlcMediaPlayer->getTime();
// qint64 length = getLength();
// qDebug() << currentTime << length;
......@@ -83,17 +81,14 @@ QPixmap* InputMedia::takeSnapshot( unsigned int width, unsigned int height
// qDebug() << "trying to take a snapshot";
QTemporaryFile tmp;
tmp.open();
char* tmpStr = const_cast<char*>(tmp.fileName().toStdString().c_str());
m_vlcMediaPlayer->takeSnapshot( tmpStr, width, height );
QTemporaryFile tmp;
tmp.open();
char* tmpStr = const_cast<char*>(tmp.fileName().toStdString().c_str());
m_vlcMediaPlayer->takeSnapshot( tmpStr, width, height );
// qDebug() << "done snapshoting";
m_snapshot = new QPixmap( tmp.fileName() );
return new QPixmap( tmp.fileName() );
// qDebug() << "written to a QImage";
// m_vlcMediaPlayer->setTime(currentTime);
}
return m_snapshot;
}
bool InputMedia::isPlaying()
......
......@@ -68,7 +68,6 @@ public:
virtual void stop();
private:
QPixmap* m_snapshot;
uchar* m_pixelBuffer;
QImage* m_image;
......
......@@ -25,7 +25,7 @@
#include <QDebug>
ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType fType, QListWidget* parent, int type ) :
QListWidgetItem( parent, type )
QListWidgetItem( parent, type ), m_fileInfo( NULL ), m_currentMedia( NULL ), m_currentMediaSnapshot( NULL )
{
m_fileInfo = fInfo;
m_fileType = fType;
......@@ -46,11 +46,16 @@ ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType
ListViewMediaItem::~ListViewMediaItem()
{
delete m_fileInfo;
if (m_currentMedia->isPlaying())
if ( m_fileInfo != NULL )
delete m_fileInfo;
if ( m_currentMedia->isPlaying() )
m_currentMedia->stop();
delete m_renderWidget;
delete m_currentMedia;
if ( m_renderWidget != NULL )
delete m_renderWidget;
if ( m_currentMedia != NULL )
delete m_currentMedia;
if ( m_currentMediaSnapshot != NULL )
delete m_currentMediaSnapshot;
}
void ListViewMediaItem::setSnapshot()
......
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