From 6eabc8bc8bfa467fa57ea95de1c3f4dde58eded1 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Kempf <jb@videolan.org>
Date: Wed, 5 Sep 2007 15:33:32 +0000
Subject: [PATCH] Qt4 - Cleanups and use QMenu on the stack to avoid leaks.
 Show menu with exec instead of popup.

---
 .../gui/qt4/components/playlist/panels.hpp    |  2 +-
 .../qt4/components/playlist/standardpanel.cpp | 22 +++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/panels.hpp b/modules/gui/qt4/components/playlist/panels.hpp
index 92213b0e185c..cab5ecf90394 100644
--- a/modules/gui/qt4/components/playlist/panels.hpp
+++ b/modules/gui/qt4/components/playlist/panels.hpp
@@ -75,7 +75,7 @@ private:
     QPushButton *repeatButton , *randomButton,*addButton;
     ClickLineEdit *searchLine;
     int currentRootId;
-QSignalMapper *ContextUpdateMapper;
+    QSignalMapper *ContextUpdateMapper;
 public slots:
     void removeItem( int );
     virtual void setRoot( int );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index a9f7aa092cde..360315e08041 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -188,32 +188,32 @@ void StandardPLPanel::setCurrentRootId( int _new )
 
 void StandardPLPanel::add()
 {
-    QMenu *popup = new QMenu();
+    QMenu popup;
     if( currentRootId == THEPL->p_local_category->i_id ||
         currentRootId == THEPL->p_local_onelevel->i_id )
     {
-        popup->addAction( qtr(I_PL_ADDF), THEDP, SLOT(simplePLAppendDialog()));
-        popup->addAction( qtr(I_PL_ADVADD), THEDP, SLOT(PLAppendDialog()) );
-        popup->addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( PLAppendDir()) );
+        popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT(simplePLAppendDialog()));
+        popup.addAction( qtr(I_PL_ADVADD), THEDP, SLOT(PLAppendDialog()) );
+        popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( PLAppendDir()) );
     }
     else if( currentRootId == THEPL->p_ml_category->i_id ||
              currentRootId == THEPL->p_ml_onelevel->i_id )
     {
-        popup->addAction( qtr(I_PL_ADDF), THEDP, SLOT(simpleMLAppendDialog()));
-        popup->addAction( qtr(I_PL_ADVADD), THEDP, SLOT( MLAppendDialog() ) );
-        popup->addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
+        popup.addAction( qtr(I_PL_ADDF), THEDP, SLOT(simpleMLAppendDialog()));
+        popup.addAction( qtr(I_PL_ADVADD), THEDP, SLOT( MLAppendDialog() ) );
+        popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
     }
-    popup->popup( QCursor::pos() );
+    popup.exec( QCursor::pos() );
 }
 
 void StandardPLPanel::popupSelectColumn( QPoint )
 {     
     ContextUpdateMapper = new QSignalMapper(this);
 
-    QMenu *selectColMenu = new QMenu( qtr("Show columns") );
+    QMenu selectColMenu;
 
 #define ADD_META_ACTION( meta ) { \
-   QAction* option = selectColMenu->addAction( qfu(VLC_META_##meta) );     \
+   QAction* option = selectColMenu.addAction( qfu(VLC_META_##meta) );     \
    option->setCheckable( true );                                           \
    option->setChecked( model->shownFlags() & VLC_META_ENGINE_##meta );   \
    ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta );      \
@@ -232,7 +232,7 @@ void StandardPLPanel::popupSelectColumn( QPoint )
 
 #undef ADD_META_ACTION
     
-    selectColMenu->popup( QCursor::pos() );
+    selectColMenu.exec( QCursor::pos() );
  }
 
 void StandardPLPanel::clearFilter()
-- 
GitLab