]> git.sesse.net Git - vlc/commitdiff
Qt4: correct fix for duplicate items in playlist - service-discovery
authorJakob Leben <jleben@videolan.org>
Tue, 27 Oct 2009 01:45:28 +0000 (02:45 +0100)
committerJakob Leben <jleben@videolan.org>
Tue, 27 Oct 2009 02:05:07 +0000 (03:05 +0100)
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.

modules/gui/qt4/components/playlist/playlist_model.cpp

index a61434cc82ec313432bae4efb532ca2bb309c855..b642dc03da9f675b7a1cf88b3fd150c974c167c6 100644 (file)
@@ -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;