[vlc-devel] commit: Qt4: correct fix for duplicate items in playlist - service-discovery ( Jakob Leben )

git version control git at videolan.org
Tue Oct 27 03:12:36 CET 2009


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Tue Oct 27 02:45:28 2009 +0100| [3dfec6e849180c7f975bebc9cee24f1bd51132a8] | committer: Jakob Leben 

Qt4: correct fix for duplicate items in playlist - service-discovery

Hypothesis: The bug stems from a thread concurrency problem. A PLModel::rebuild() happens
just between SD inserting items into the core playlist and Qt playlist receiving item-added callback.
Thus, the items referred to the callback are inserted twice into the Qt playlist.

Solution: check if item already inserted at callback processing.

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

 .../gui/qt4/components/playlist/playlist_model.cpp |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index a61434c..b642dc0 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -667,6 +667,9 @@ void PLModel::processItemAppend( const playlist_add_t *p_add )
     PLItem *nodeItem = findById( rootItem, p_add->i_node );
     if( !nodeItem ) return;
 
+		foreach( PLItem *existing, nodeItem->children )
+			if( existing->i_id == p_add->i_item ) { return; }
+
     PL_LOCK;
     p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
     if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;




More information about the vlc-devel mailing list