fix: crash caused by urlByIndex() with invalid model index
Also save a QVariant convert for QUrl
This commit is contained in:
@ -104,6 +104,11 @@ int PlaylistModel::indexOf(const QUrl &url) const
|
||||
return m_playlist.indexOf(url);
|
||||
}
|
||||
|
||||
QUrl PlaylistModel::urlByIndex(int index) const
|
||||
{
|
||||
return m_playlist.value(index);
|
||||
}
|
||||
|
||||
QStringList PlaylistModel::autoLoadFilterSuffixes() const
|
||||
{
|
||||
return m_autoLoadSuffixes;
|
||||
@ -157,7 +162,7 @@ PlaylistManager::~PlaylistManager()
|
||||
|
||||
}
|
||||
|
||||
const PlaylistModel *PlaylistManager::model() const
|
||||
PlaylistModel *PlaylistManager::model()
|
||||
{
|
||||
return &m_model;
|
||||
}
|
||||
@ -174,6 +179,13 @@ QModelIndex PlaylistManager::loadPlaylist(const QList<QUrl> &urls)
|
||||
return idx;
|
||||
}
|
||||
|
||||
QModelIndex PlaylistManager::loadPlaylist(const QUrl &url)
|
||||
{
|
||||
QModelIndex idx = m_model.loadPlaylist(url);
|
||||
setProperty("currentIndex", idx.row());
|
||||
return idx;
|
||||
}
|
||||
|
||||
int PlaylistManager::totalCount() const
|
||||
{
|
||||
return m_model.rowCount();
|
||||
@ -209,7 +221,7 @@ void PlaylistManager::setCurrentIndex(const QModelIndex &index)
|
||||
|
||||
QUrl PlaylistManager::urlByIndex(const QModelIndex &index)
|
||||
{
|
||||
return m_model.data(index, PlaylistModel::UrlRole).toUrl();
|
||||
return m_model.urlByIndex(index.row());
|
||||
}
|
||||
|
||||
QString PlaylistManager::localFileByIndex(const QModelIndex &index)
|
||||
|
Reference in New Issue
Block a user