[vlc-devel] [PATCH 2/2] Adding "save to playlist" menu item in submenu Recents. FIX

bl3nder bl3nderb at aol.com
Sat Oct 12 18:21:20 CEST 2013


this commit includes fixes related to Jean-Baptiste Kempf code review.
 - fixing whitespace problem
 - RecentsMRL::toPlaylist null handling
---
 modules/gui/qt4/dialogs_provider.cpp |   17 ++++++++++++-----
 modules/gui/qt4/dialogs_provider.hpp |    2 +-
 modules/gui/qt4/recents.cpp          |   20 +++++++++++---------
 modules/gui/qt4/recents.hpp          |    2 +-
 4 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp
index fc7411a..cc68160 100644
--- a/modules/gui/qt4/dialogs_provider.cpp
+++ b/modules/gui/qt4/dialogs_provider.cpp
@@ -81,7 +81,7 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
              this, menuUpdateAction( QObject *) );
 
     SDMapper = new QSignalMapper();
-    CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) ); 
+    CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
 
     new DialogHandler (p_intf, this );
 }
@@ -654,14 +654,21 @@ void DialogsProvider::saveAPlaylist(playlist_t *p_playlist, playlist_item_t *p_n
 
 void DialogsProvider::savePlayingToPlaylist()
 {
-	saveAPlaylist(THEPL, THEPL->p_playing);
+    saveAPlaylist(THEPL, THEPL->p_playing);
 }
 
 void DialogsProvider::saveRecentsToPlaylist()
 {
-	playlist_item_t *p_node_recents = RecentsMRL::getInstance(p_intf)->toPlaylist(0);
-	saveAPlaylist(THEPL, p_node_recents);
-	playlist_NodeDelete(THEPL, p_node_recents, true, false);
+    playlist_item_t *p_node_recents = RecentsMRL::getInstance(p_intf)->toPlaylist(0);
+
+    if (p_node_recents == NULL)
+    {
+        msg_Warn(p_intf, "cannot create playlist from recents");
+        return;
+    }
+
+    saveAPlaylist(THEPL, p_node_recents);
+    playlist_NodeDelete(THEPL, p_node_recents, true, false);
 }
 
 /****************************************************************************
diff --git a/modules/gui/qt4/dialogs_provider.hpp b/modules/gui/qt4/dialogs_provider.hpp
index aa789be..00bd37c 100644
--- a/modules/gui/qt4/dialogs_provider.hpp
+++ b/modules/gui/qt4/dialogs_provider.hpp
@@ -163,7 +163,7 @@ public slots:
 
     void openAPlaylist();
     void savePlayingToPlaylist();
-    void saveRecentsToPlaylist();  
+    void saveRecentsToPlaylist();
 
     void loadSubtitlesFile();
 
diff --git a/modules/gui/qt4/recents.cpp b/modules/gui/qt4/recents.cpp
index 6388901..316b6ee 100755
--- a/modules/gui/qt4/recents.cpp
+++ b/modules/gui/qt4/recents.cpp
@@ -151,16 +151,18 @@ void RecentsMRL::save()
 
 playlist_item_t *RecentsMRL::toPlaylist(int length)
 {
-	playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG, NULL);		
+    playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG, NULL);
 
-	if (length == 0 || stack->count() < length)
-		length = stack->count();
+    if ( p_node_recent == NULL )  return NULL;
 
-	for (int i = 0; i < length; i++)
-	{
-		input_item_t *p_input = input_item_New(qtu(stack->at(i)), NULL);
-		playlist_NodeAddInput(THEPL, p_input, p_node_recent, PLAYLIST_APPEND, PLAYLIST_END, false);
-	}
+    if (length == 0 || stack->count() < length)
+        length = stack->count();
 
-	return p_node_recent;
+    for (int i = 0; i < length; i++)
+    {
+        input_item_t *p_input = input_item_New(qtu(stack->at(i)), NULL);
+        playlist_NodeAddInput(THEPL, p_input, p_node_recent, PLAYLIST_APPEND, PLAYLIST_END, false);
+    }
+
+    return p_node_recent;
 }
diff --git a/modules/gui/qt4/recents.hpp b/modules/gui/qt4/recents.hpp
index 29805a3..ebcf747 100644
--- a/modules/gui/qt4/recents.hpp
+++ b/modules/gui/qt4/recents.hpp
@@ -53,8 +53,8 @@ public:
     void addRecent( const QString & );
     QStringList recents();
     playlist_item_t *toPlaylist(int length);
-   
     QSignalMapper *signalMapper;
+
 private:
     RecentsMRL( intf_thread_t* _p_intf );
     virtual ~RecentsMRL();
-- 
1.7.9.5




More information about the vlc-devel mailing list