From: APTX Date: Mon, 27 Apr 2009 12:53:31 +0000 (+0200) Subject: - Fix crash if playlist is empty X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=73246001752802cff8d646a8b735553287d88901;p=aniplayer-old.git - Fix crash if playlist is empty --- diff --git a/src/directoryplaylist.cpp b/src/directoryplaylist.cpp index 017e6ec..a5d8c8e 100644 --- a/src/directoryplaylist.cpp +++ b/src/directoryplaylist.cpp @@ -35,10 +35,6 @@ void DirectoryPlaylist::setDirectory(QDir directory) QDir::Files | QDir::Readable, QDir::Name); m_currentIndex = 0; -foreach(const QFileInfo &f, entryList) -{ - qDebug() << f.absoluteFilePath(); -} } int DirectoryPlaylist::indexOfFile(const QString &file) const @@ -66,6 +62,9 @@ int DirectoryPlaylist::currentIndex() const void DirectoryPlaylist::next() { + if (entryList.isEmpty()) + return; + ++m_currentIndex; if (m_currentIndex == count()) m_currentIndex = 0; @@ -76,6 +75,9 @@ void DirectoryPlaylist::next() void DirectoryPlaylist::previous() { + if (entryList.isEmpty()) + return; + --m_currentIndex; if (m_currentIndex == -1) m_currentIndex = count() - 1;