Commit eaac4b87 authored by Christophe Courtaut's avatar Christophe Courtaut

Fixed leaks and now can't add two times same media

parent 6e0740a7
...@@ -80,8 +80,14 @@ ListViewMediaItem* LibraryWidget::insertNewMediaFromFileDialog( Q ...@@ -80,8 +80,14 @@ ListViewMediaItem* LibraryWidget::insertNewMediaFromFileDialog( Q
QString fileName = QFileDialog::getOpenFileName( this, title, QDir::homePath(), filter); QString fileName = QFileDialog::getOpenFileName( this, title, QDir::homePath(), filter);
if ( fileName == "" ) if ( fileName == "" )
return NULL; return NULL;
ListViewMediaItem* item = NULL;
foreach( item, *m_medias )
{
if (item->fileInfo->absoluteFilePath() == fileName)
return item;
}
QFileInfo* fileInfo = new QFileInfo( fileName ); QFileInfo* fileInfo = new QFileInfo( fileName );
ListViewMediaItem* item = this->addMedia( fileInfo, fileType ); item = this->addMedia( fileInfo, fileType );
return item; return item;
} }
...@@ -114,6 +120,11 @@ ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType ...@@ -114,6 +120,11 @@ ListViewMediaItem::ListViewMediaItem( QFileInfo* fInfo, ListViewMediaItem::fType
setText( fileInfo->baseName() ); setText( fileInfo->baseName() );
} }
ListViewMediaItem::~ListViewMediaItem()
{
delete this->fileInfo;
}
void ListViewMediaItem::mousePressEvent( QMouseEvent* event ) void ListViewMediaItem::mousePressEvent( QMouseEvent* event )
{ {
} }
......
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
}; };
ListViewMediaItem( QFileInfo* fileInfo, ListViewMediaItem::fType fType, QListWidget* parent = 0, int type = Type ); ListViewMediaItem( QFileInfo* fileInfo, ListViewMediaItem::fType fType, QListWidget* parent = 0, int type = Type );
virtual ~ListViewMediaItem();
QFileInfo* fileInfo; QFileInfo* fileInfo;
ListViewMediaItem::fType fileType; ListViewMediaItem::fType fileType;
protected: protected:
......
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