Commit b25c744a authored by Ludovic Fauvet's avatar Ludovic Fauvet

Fix memleak

parent 3ce9a72b
/*****************************************************************************
* LibraryWidget.cpp: VLMC LibraryWidget
* LibraryWidget.cpp: Multimedia library
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
......@@ -33,6 +33,16 @@ LibraryWidget::LibraryWidget( QWidget *parent ) : QWidget( parent )
LibraryWidget::m_medias = new QList<ListViewMediaItem*>();
}
LibraryWidget::~LibraryWidget()
{
if ( LibraryWidget::m_medias )
{
while ( !LibraryWidget::m_medias->isEmpty() )
delete LibraryWidget::m_medias->takeLast();
delete LibraryWidget::m_medias;
}
}
ListViewMediaItem* LibraryWidget::addMedia( QFileInfo* fileInfo, ListViewMediaItem::fType fileType )
{
ListViewMediaItem* item = new ListViewMediaItem( fileInfo, fileType );
......@@ -78,7 +88,7 @@ bool LibraryWidget::removeMedia(ListViewMediaItem* item)
ListViewMediaItem* LibraryWidget::insertNewMediaFromFileDialog( QString title, QString filter, ListViewMediaItem::fType fileType )
{
QString fileName = QFileDialog::getOpenFileName( this, title, QDir::homePath(), filter);
if ( fileName == "" )
if ( fileName.isEmpty() )
return NULL;
ListViewMediaItem* item = NULL;
foreach( item, *m_medias )
......
/*****************************************************************************
* LibraryWidget.h: VLMC library widget header
* LibraryWidget.h: Multimedia library
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
......@@ -42,6 +42,7 @@ class LibraryWidget : public QWidget
public:
explicit LibraryWidget( QWidget *parent = 0 );
virtual ~LibraryWidget();
ListViewMediaItem* addMedia( QFileInfo* fileInfo, ListViewMediaItem::fType fileType );
bool removeMedia( ListViewMediaItem* item );
......@@ -60,5 +61,4 @@ private slots:
void on_pushButtonRemoveMedia_clicked();
};
#endif /* !LIBRARYWIDGET_H */
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