]> git.sesse.net Git - vlc/commitdiff
skins2: fix proccessing item-change at playlist level
authorErwan Tulou <erwan10@videolan.org>
Sat, 13 Feb 2010 17:09:58 +0000 (18:09 +0100)
committerErwan Tulou <erwan10@videolan.org>
Sat, 13 Feb 2010 17:29:52 +0000 (18:29 +0100)
it is needed to pass from input_item_t to playlist_item_t
 for this variable only (others directly provide playlist_item_t)

modules/gui/skins2/commands/cmd_vars.cpp
modules/gui/skins2/commands/cmd_vars.hpp
modules/gui/skins2/src/vlcproc.cpp

index 60129d549e625a0724df1e922584810fd5042bc7..b14c402d745337175424712b79f5a70c86bb4d4d 100644 (file)
@@ -35,14 +35,24 @@ void CmdPlaytreeChanged::execute()
 
 void CmdPlaytreeUpdate::execute()
 {
-    VlcProc::instance( getIntf() )->getPlaytreeVar().onUpdateItem( m_id );
+    if( !m_pItem )
+        return;
+
+    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
+    playlist_Lock( pPlaylist );
+    playlist_item_t* p_plItem = playlist_ItemGetByInput( pPlaylist, m_pItem );
+    int id = p_plItem ? p_plItem->i_id : 0;
+    playlist_Unlock( pPlaylist );
+
+    if( id )
+        VlcProc::instance( getIntf() )->getPlaytreeVar().onUpdateItem( id );
 }
 
 bool CmdPlaytreeUpdate::checkRemove( CmdGeneric *pQueuedCommand ) const
 {
     // We don't use RTTI - Use C-style cast
     CmdPlaytreeUpdate *pUpdateCommand = (CmdPlaytreeUpdate *)(pQueuedCommand);
-    return m_id == pUpdateCommand->m_id;
+    return m_pItem == pUpdateCommand->m_pItem;
 }
 
 
index 1733fb155d7a4b83d01e13010eb5f3d0998b429c..c6f926eadea3cdf9ba2a5e17a08a5e93e68eeca0 100644 (file)
@@ -24,6 +24,9 @@
 #ifndef CMD_VARS_HPP
 #define CMD_VARS_HPP
 
+#include <vlc_common.h>
+#include <vlc_playlist.h>
+
 #include "cmd_generic.hpp"
 #include "../utils/ustring.hpp"
 
@@ -41,9 +44,17 @@ DEFINE_COMMAND( PlaytreeChanged, "playtree changed" )
 class CmdPlaytreeUpdate: public CmdGeneric
 {
 public:
-    CmdPlaytreeUpdate( intf_thread_t *pIntf, int id ):
-        CmdGeneric( pIntf ), m_id( id ) { }
-    virtual ~CmdPlaytreeUpdate() { }
+    CmdPlaytreeUpdate( intf_thread_t *pIntf, input_item_t* pItem ):
+        CmdGeneric( pIntf ), m_pItem( pItem )
+    {
+        if( pItem )
+            vlc_gc_incref( pItem );
+    }
+    virtual ~CmdPlaytreeUpdate()
+    {
+        if( m_pItem )
+            vlc_gc_decref( m_pItem );
+    }
     virtual void execute();
     virtual string getType() const { return "playtree update"; }
 
@@ -51,8 +62,8 @@ public:
     virtual bool checkRemove( CmdGeneric * ) const;
 
 private:
-    /// Playlist item ID
-    int m_id;
+    /// input item changed
+    input_item_t* m_pItem;
 };
 
 /// Command to notify the playtree of an item append
index cc52532ae856146b370af77a3d0901376de7bf27..59ad84a7016ed2386961fe951108d7680969566a 100644 (file)
@@ -267,24 +267,17 @@ int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
                            vlc_value_t oldval, vlc_value_t newval,
                            void *pParam )
 {
-    // TODO: FIXME
-    // Deactivated because it mixes up i_id from input_item_t
-    // and i_id from playlist_item_t
-#if 0
-
     VlcProc *pThis = (VlcProc*)pParam;
     input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
 
     // Create a playtree notify command
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
-                                                         p_item->i_id );
+                                                         p_item );
 
     // Push the command in the asynchronous command queue
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
     pQueue->push( CmdGenericPtr( pCmdTree ), true );
 
-#endif
-
     return VLC_SUCCESS;
 }