[vlc-commits] skins: use playlist item ID for append (as for delete)
Rémi Denis-Courmont
git at videolan.org
Tue Nov 15 23:09:58 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov 15 23:55:27 2016 +0200| [88ca3f3852910eeb7553c7fc38827a8c4a5c8c76] | committer: Rémi Denis-Courmont
skins: use playlist item ID for append (as for delete)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=88ca3f3852910eeb7553c7fc38827a8c4a5c8c76
---
modules/gui/skins2/commands/cmd_vars.cpp | 2 +-
modules/gui/skins2/commands/cmd_vars.hpp | 19 +++---------
modules/gui/skins2/src/vlcproc.cpp | 2 +-
modules/gui/skins2/vars/playtree.cpp | 53 +++++++++++++++++---------------
modules/gui/skins2/vars/playtree.hpp | 2 +-
5 files changed, 36 insertions(+), 42 deletions(-)
diff --git a/modules/gui/skins2/commands/cmd_vars.cpp b/modules/gui/skins2/commands/cmd_vars.cpp
index dfde4f3..7efdc28 100644
--- a/modules/gui/skins2/commands/cmd_vars.cpp
+++ b/modules/gui/skins2/commands/cmd_vars.cpp
@@ -63,7 +63,7 @@ bool CmdItemUpdate::checkRemove( CmdGeneric *pQueuedCommand ) const
void CmdPlaytreeAppend::execute()
{
- VlcProc::instance( getIntf() )->getPlaytreeVar().onAppend( m_pAdd );
+ VlcProc::instance( getIntf() )->getPlaytreeVar().onAppend( m_id );
}
void CmdPlaytreeDelete::execute()
diff --git a/modules/gui/skins2/commands/cmd_vars.hpp b/modules/gui/skins2/commands/cmd_vars.hpp
index 4ca832c..26e29a7 100644
--- a/modules/gui/skins2/commands/cmd_vars.hpp
+++ b/modules/gui/skins2/commands/cmd_vars.hpp
@@ -69,24 +69,15 @@ private:
class CmdPlaytreeAppend: public CmdGeneric
{
public:
- CmdPlaytreeAppend( intf_thread_t *pIntf, playlist_add_t *p_add ):
- CmdGeneric( pIntf ), m_pAdd( NULL )
- {
- if( p_add )
- {
- m_pAdd = new playlist_add_t;
- *m_pAdd = *p_add;
- }
- }
- virtual ~CmdPlaytreeAppend()
- {
- delete m_pAdd;
- }
+ CmdPlaytreeAppend( intf_thread_t *pIntf, int i_id ):
+ CmdGeneric( pIntf ), m_id( i_id )
+ { }
+ virtual ~CmdPlaytreeAppend() { }
virtual void execute();
virtual std::string getType() const { return "playtree append"; }
private:
- playlist_add_t * m_pAdd;
+ int m_id;
};
/// Command to notify the playtree of an item deletion
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 1ec10ee..21b37f2 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -266,7 +266,7 @@ int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
CmdPlaytreeAppend *pCmdTree =
- new CmdPlaytreeAppend( pThis->getIntf(), p_add );
+ new CmdPlaytreeAppend( pThis->getIntf(), p_add->i_item );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
diff --git a/modules/gui/skins2/vars/playtree.cpp b/modules/gui/skins2/vars/playtree.cpp
index 93ca405..74d516c 100644
--- a/modules/gui/skins2/vars/playtree.cpp
+++ b/modules/gui/skins2/vars/playtree.cpp
@@ -205,40 +205,43 @@ void Playtree::onDelete( int i_id )
}
}
-void Playtree::onAppend( playlist_add_t *p_add )
+void Playtree::onAppend( int i_id )
{
- Iterator it_node = findById( p_add->i_node );
+ playlist_item_t *pItem;
+
+ playlist_Lock( m_pPlaylist );
+ pItem = playlist_ItemGetById( m_pPlaylist, i_id );
+ if( !pItem || !pItem->p_parent )
+ {
+ playlist_Unlock( m_pPlaylist );
+ return;
+ }
+
+ Iterator it_node = findById( pItem->p_parent->i_id );
if( it_node != m_children.end() )
{
- playlist_Lock( m_pPlaylist );
- playlist_item_t *pItem =
- playlist_ItemGetById( m_pPlaylist, p_add->i_item );
- if( !pItem )
- {
- playlist_Unlock( m_pPlaylist );
- return;
- }
+ playlist_Unlock( m_pPlaylist );
+ return;
+ }
- int pos;
- for( pos = 0; pos < pItem->p_parent->i_children; pos++ )
- if( pItem->p_parent->pp_children[pos] == pItem ) break;
+ int pos;
+ for( pos = 0; pos < pItem->p_parent->i_children; pos++ )
+ if( pItem->p_parent->pp_children[pos] == pItem ) break;
- UString *pName = getTitle( pItem->p_input );
- playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist );
+ UString *pName = getTitle( pItem->p_input );
+ playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist );
- Iterator it = it_node->add(
- p_add->i_item, UStringPtr( pName ), false, pItem == current,
- false, pItem->i_flags & PLAYLIST_RO_FLAG, pos );
+ Iterator it = it_node->add(
+ i_id, UStringPtr( pName ), false, pItem == current,
+ false, pItem->i_flags & PLAYLIST_RO_FLAG, pos );
- m_allItems[pItem->i_id] = &*it;
+ m_allItems[i_id] = &*it;
- playlist_Unlock( m_pPlaylist );
+ playlist_Unlock( m_pPlaylist );
- tree_update descr(
- tree_update::ItemInserted,
- IteratorVisible( it, this ) );
- notify( &descr );
- }
+ tree_update descr( tree_update::ItemInserted,
+ IteratorVisible( it, this ) );
+ notify( &descr );
}
void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
diff --git a/modules/gui/skins2/vars/playtree.hpp b/modules/gui/skins2/vars/playtree.hpp
index f825ba0..ed930ee 100644
--- a/modules/gui/skins2/vars/playtree.hpp
+++ b/modules/gui/skins2/vars/playtree.hpp
@@ -53,7 +53,7 @@ public:
void onUpdateCurrent( bool b_active );
/// Function called to notify playlist item append
- void onAppend( playlist_add_t * );
+ void onAppend( int );
/// Function called to notify playlist item delete
void onDelete( int );
More information about the vlc-commits
mailing list