Commit a403be13 authored by Jean-Philippe Andre's avatar Jean-Philippe Andre

Qt: Add a parent to the CoverArtLabel We should add parents to all QWidgets...

Qt: Add a parent to the CoverArtLabel We should add parents to all QWidgets created, otherwise the widgets are leaked This commit is buggy (can leak input_items), because the whole Qt implementation is leaking QWidgets
parent db44bc22
...@@ -106,7 +106,7 @@ MetaPanel::MetaPanel( QWidget *parent, ...@@ -106,7 +106,7 @@ MetaPanel::MetaPanel( QWidget *parent,
line++; line++;
/* ART_URL */ /* ART_URL */
art_cover = new CoverArtLabel( VLC_OBJECT( p_intf ) ); art_cover = new CoverArtLabel( this, VLC_OBJECT( p_intf ) );
metaLayout->addWidget( art_cover, line, 8, 4, 2, Qt::AlignRight ); metaLayout->addWidget( art_cover, line, 8, 4, 2, Qt::AlignRight );
/* Settings is unused */ /* Settings is unused */
......
...@@ -159,13 +159,5 @@ public slots: ...@@ -159,13 +159,5 @@ public slots:
void update( input_item_t * ); void update( input_item_t * );
void clear(); void clear();
}; };
class ArtCover : public QLabel
{
Q_OBJECT
void mouseDoubleClickEvent( QMouseEvent *event )
{
fprintf(stderr, "**************************" );
}
};
#endif #endif
...@@ -1467,8 +1467,10 @@ static int downloadCoverCallback( vlc_object_t *p_this, ...@@ -1467,8 +1467,10 @@ static int downloadCoverCallback( vlc_object_t *p_this,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
CoverArtLabel::CoverArtLabel( vlc_object_t *_p_this, input_item_t *_p_input ) CoverArtLabel::CoverArtLabel( QWidget *parent,
: p_this( _p_this), p_input( _p_input ), prevArt() vlc_object_t *_p_this,
input_item_t *_p_input )
: QLabel( parent ), p_this( _p_this), p_input( _p_input ), prevArt()
{ {
setContextMenuPolicy( Qt::ActionsContextMenu ); setContextMenuPolicy( Qt::ActionsContextMenu );
CONNECT( this, updateRequested(), this, doUpdate() ); CONNECT( this, updateRequested(), this, doUpdate() );
......
...@@ -380,8 +380,11 @@ class CoverArtLabel : public QLabel ...@@ -380,8 +380,11 @@ class CoverArtLabel : public QLabel
{ {
Q_OBJECT Q_OBJECT
public: public:
CoverArtLabel( vlc_object_t *p_this, input_item_t *p_input = NULL ); CoverArtLabel( QWidget *parent,
virtual ~CoverArtLabel() {}; vlc_object_t *p_this,
input_item_t *p_input = NULL );
virtual ~CoverArtLabel()
{ if( p_input ) vlc_gc_decref( p_input ); };
private: private:
input_item_t *p_input; input_item_t *p_input;
vlc_object_t *p_this; vlc_object_t *p_this;
......
...@@ -64,7 +64,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, ...@@ -64,7 +64,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i,
artContainer->setMaximumHeight( 128 ); artContainer->setMaximumHeight( 128 );
/* Art label */ /* Art label */
art = new ArtLabel( p_intf ); art = new ArtLabel( artContainer, p_intf );
art->setToolTip( qtr( "Double click to get media information" ) ); art->setToolTip( qtr( "Double click to get media information" ) );
artContLay->addWidget( art, 1 ); artContLay->addWidget( art, 1 );
......
...@@ -70,7 +70,8 @@ class ArtLabel : public CoverArtLabel ...@@ -70,7 +70,8 @@ class ArtLabel : public CoverArtLabel
{ {
Q_OBJECT Q_OBJECT
public: public:
ArtLabel( intf_thread_t *intf ) : CoverArtLabel( VLC_OBJECT( intf ) ) {}; ArtLabel( QWidget *parent, intf_thread_t *intf )
: CoverArtLabel( parent, VLC_OBJECT( intf ) ) {};
virtual ~ArtLabel() {}; virtual ~ArtLabel() {};
void mouseDoubleClickEvent( QMouseEvent *event ) void mouseDoubleClickEvent( QMouseEvent *event )
{ {
......
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