[vlc-commits] gui/qt: fix crash when sorting playlist
Filip Roséen
git at videolan.org
Fri Jul 8 16:03:26 CEST 2016
vlc | branch: master | Filip Roséen <filip at videolabs.io> | Fri Jul 8 03:50:23 2016 +0200| [94feeecdbba572726fd336daf94a5a8b35371074] | committer: 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 <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=94feeecdbba572726fd336daf94a5a8b35371074
---
modules/gui/qt/components/playlist/playlist_model.cpp | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index 1ee67a7..2df4722 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -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 )
More information about the vlc-commits
mailing list