Commit 94feeecd authored by Filip Roséen's avatar Filip Roséen Committed by Jean-Baptiste Kempf

gui/qt: fix crash when sorting playlist

Close #17023

The problem behind the issue is that the QModelIndex sent
through "emit currentIndexChanged( ... )" previously referred to an
AbstractPLItem that is destroyed during the playlist sorting.

This fixes the issue by grabbing the associated input_item_t*
prior to sorting/destroying the item list, and then conditionally using
the retrieved handle to construct a new QModelIndex (referring to the
correct entity), referring to the correct entity within the
recontrustructed list.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent b11a53f9
......@@ -794,6 +794,10 @@ void PLModel::sort( QModelIndex caller, QModelIndex rootIndex, const int column,
: rootItem;
if( !item ) return;
input_item_t* p_caller_item = caller.isValid()
? static_cast<AbstractPLItem*>( caller.internalPointer() )->inputItem()
: NULL;
int i_root_id = item->id( PLAYLIST_ID );
QModelIndex qIndex = index( item, 0 );
......@@ -825,10 +829,16 @@ void PLModel::sort( QModelIndex caller, QModelIndex rootIndex, const int column,
endInsertRows( );
}
PL_UNLOCK;
/* if we have popup item, try to make sure that you keep that item visible */
if( caller.isValid() ) emit currentIndexChanged( caller );
if( p_caller_item )
{
QModelIndex idx = indexByInputItemID( p_caller_item->i_id, 0 );
else if( currentIndex().isValid() ) emit currentIndexChanged( currentIndex() );
emit currentIndexChanged( idx );
}
else if( currentIndex().isValid() )
emit currentIndexChanged( currentIndex() );
}
void PLModel::filter( const QString& search_text, const QModelIndex & idx, bool b_recursive )
......
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