1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

Fixed TWK-1454: Don't crash when trying to set invalid current index.

This commit is contained in:
Christian Muehlhaeuser
2014-11-12 11:05:58 +01:00
parent 7cd0526d95
commit f2235cee55
2 changed files with 13 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
@@ -61,10 +61,11 @@ AlbumPlaylistInterface::~AlbumPlaylistInterface()
void
AlbumPlaylistInterface::setCurrentIndex( qint64 index )
{
if ( index < m_queries.size() && !m_queries.at( index ).isNull() && m_queries.at( index )->results().size() > 0 ) {
PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first();
if ( index >= 0 && index < m_queries.size() &&
!m_queries.at( index ).isNull() && m_queries.at( index )->results().size() > 0 )
{
PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first();
}
}

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
@@ -53,9 +53,12 @@ ArtistPlaylistInterface::~ArtistPlaylistInterface()
void
ArtistPlaylistInterface::setCurrentIndex( qint64 index )
{
PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first();
if ( index >= 0 && index < m_queries.size() &&
!m_queries.at( index ).isNull() && m_queries.at( index )->results().size() > 0 )
{
PlaylistInterface::setCurrentIndex( index );
m_currentItem = m_queries.at( index )->results().first();
}
}