From a403be13cf0f5565cfa5ca27f845219bf13ab1af Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 12 Sep 2008 00:24:28 -0400 Subject: [PATCH] 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 --- modules/gui/qt4/components/info_panels.cpp | 2 +- modules/gui/qt4/components/info_panels.hpp | 8 -------- modules/gui/qt4/components/interface_widgets.cpp | 6 ++++-- modules/gui/qt4/components/interface_widgets.hpp | 7 +++++-- modules/gui/qt4/components/playlist/playlist.cpp | 2 +- modules/gui/qt4/components/playlist/playlist.hpp | 3 ++- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp index 5b78c9b766..a6c7f88b1f 100644 --- a/modules/gui/qt4/components/info_panels.cpp +++ b/modules/gui/qt4/components/info_panels.cpp @@ -106,7 +106,7 @@ MetaPanel::MetaPanel( QWidget *parent, line++; /* 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 ); /* Settings is unused */ diff --git a/modules/gui/qt4/components/info_panels.hpp b/modules/gui/qt4/components/info_panels.hpp index 5a948e45e9..ed2d8d51d4 100644 --- a/modules/gui/qt4/components/info_panels.hpp +++ b/modules/gui/qt4/components/info_panels.hpp @@ -159,13 +159,5 @@ public slots: void update( input_item_t * ); void clear(); }; -class ArtCover : public QLabel -{ - Q_OBJECT - void mouseDoubleClickEvent( QMouseEvent *event ) - { - fprintf(stderr, "**************************" ); - } -}; #endif diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index 2b04e5eb86..4edc1271f9 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -1467,8 +1467,10 @@ static int downloadCoverCallback( vlc_object_t *p_this, return VLC_SUCCESS; } -CoverArtLabel::CoverArtLabel( vlc_object_t *_p_this, input_item_t *_p_input ) - : p_this( _p_this), p_input( _p_input ), prevArt() +CoverArtLabel::CoverArtLabel( QWidget *parent, + vlc_object_t *_p_this, + input_item_t *_p_input ) + : QLabel( parent ), p_this( _p_this), p_input( _p_input ), prevArt() { setContextMenuPolicy( Qt::ActionsContextMenu ); CONNECT( this, updateRequested(), this, doUpdate() ); diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp index f6dd9240d5..85d50e1ce8 100644 --- a/modules/gui/qt4/components/interface_widgets.hpp +++ b/modules/gui/qt4/components/interface_widgets.hpp @@ -380,8 +380,11 @@ class CoverArtLabel : public QLabel { Q_OBJECT public: - CoverArtLabel( vlc_object_t *p_this, input_item_t *p_input = NULL ); - virtual ~CoverArtLabel() {}; + CoverArtLabel( QWidget *parent, + vlc_object_t *p_this, + input_item_t *p_input = NULL ); + virtual ~CoverArtLabel() + { if( p_input ) vlc_gc_decref( p_input ); }; private: input_item_t *p_input; vlc_object_t *p_this; diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp index a16d39e817..6731356fa8 100644 --- a/modules/gui/qt4/components/playlist/playlist.cpp +++ b/modules/gui/qt4/components/playlist/playlist.cpp @@ -64,7 +64,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, artContainer->setMaximumHeight( 128 ); /* Art label */ - art = new ArtLabel( p_intf ); + art = new ArtLabel( artContainer, p_intf ); art->setToolTip( qtr( "Double click to get media information" ) ); artContLay->addWidget( art, 1 ); diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp index 71180e0c0f..cb48b9cf95 100644 --- a/modules/gui/qt4/components/playlist/playlist.hpp +++ b/modules/gui/qt4/components/playlist/playlist.hpp @@ -70,7 +70,8 @@ class ArtLabel : public CoverArtLabel { Q_OBJECT public: - ArtLabel( intf_thread_t *intf ) : CoverArtLabel( VLC_OBJECT( intf ) ) {}; + ArtLabel( QWidget *parent, intf_thread_t *intf ) + : CoverArtLabel( parent, VLC_OBJECT( intf ) ) {}; virtual ~ArtLabel() {}; void mouseDoubleClickEvent( QMouseEvent *event ) { -- 2.39.2