Commit 8a38e84f authored by Filip Roséen's avatar Filip Roséen Committed by François Cartegnie

gui/qt: fix PLModel::getPLRootType

This commit fixes the below:

 - Since we are dealing with the playlist, it should be locked for the
   operations inside PLModel::getPLRootType.

 - There is a problem associated with comparing the value of the
   different node's p_input (input_item_t*).

   Given that the input_item_t* can be shared across several nodes, we
   could end up in a state where the prior implementation leads to a
   false-positive.
Signed-off-by: François Cartegnie's avatarFrancois Cartegnie <fcvlcdev@free.fr>
parent 52f31595
......@@ -553,16 +553,17 @@ PLItem * PLModel::findInner( PLItem *root, int i_id, bool b_isinputid ) const
PLModel::pl_nodetype PLModel::getPLRootType() const
{
vlc_playlist_locker pl_lock ( THEPL );
/* can't rely on rootitem as it depends on view / rebuild() */
AbstractPLItem *plitem = rootItem;
while( plitem->parent() ) plitem = plitem->parent();
while( plitem->parent() )plitem = plitem->parent();
const input_item_t *p_item = plitem->inputItem();
if( p_item == p_playlist->p_playing->p_input )
if( plitem->id( PLAYLIST_ID ) == p_playlist->p_playing->i_id )
return ROOTTYPE_CURRENT_PLAYING;
if( p_playlist->p_media_library &&
p_item == p_playlist->p_media_library->p_input )
plitem->id( PLAYLIST_ID ) == p_playlist->p_media_library->i_id )
return ROOTTYPE_MEDIA_LIBRARY;
return ROOTTYPE_OTHER;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment