[vlc-devel] commit: 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 ( Jean-Philippe Andre )

git version control git at videolan.org
Fri Sep 12 07:23:25 CEST 2008


vlc | branch: master | Jean-Philippe Andre <jpeg at via.ecp.fr> | Fri Sep 12 00:24:28 2008 -0400| [a403be13cf0f5565cfa5ca27f845219bf13ab1af] | committer: Jean-Philippe Andre 

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a403be13cf0f5565cfa5ca27f845219bf13ab1af
---

 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 5b78c9b..a6c7f88 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 5a948e4..ed2d8d5 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 2b04e5e..4edc127 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 f6dd924..85d50e1 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 a16d39e..6731356 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 71180e0..cb48b9c 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 )
     {




More information about the vlc-devel mailing list