Emit mediaAboutToBeRemoved() before mediaRemoved() in QMediaPlaylist.

When a new playlist's mediaObject is set, the content is cleared and the
mediaRemoved() signal is emitted without a former
mediaAboutToBeRemoved(). This is an issue for QAbstractItemModel
implementations, like the coming QDeclarativePlaylist, which call
beginInsertRow() and endInsertRows() in the respective signal handlers.

Change-Id: I7ec512ff2736e92858df94d9479741e05162e1f0
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
This commit is contained in:
Loïc Molinari
2015-08-10 13:38:47 +02:00
committed by Yoann Lopes
parent 475a14ccc3
commit 6684b4b23b

View File

@@ -214,8 +214,10 @@ bool QMediaPlaylist::setMediaObject(QMediaObject *mediaObject)
connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)), connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)),
this, SIGNAL(currentMediaChanged(QMediaContent))); this, SIGNAL(currentMediaChanged(QMediaContent)));
if (oldSize) if (oldSize) {
emit mediaAboutToBeRemoved(0, oldSize-1);
emit mediaRemoved(0, oldSize-1); emit mediaRemoved(0, oldSize-1);
}
if (playlist->mediaCount()) { if (playlist->mediaCount()) {
emit mediaAboutToBeInserted(0,playlist->mediaCount()-1); emit mediaAboutToBeInserted(0,playlist->mediaCount()-1);