]> Some of my projects - aniplayer-old.git/commitdiff
- Fix crash if playlist is empty
authorAPTX <APTX@.(none)>
Mon, 27 Apr 2009 12:53:31 +0000 (14:53 +0200)
committerAPTX <APTX@.(none)>
Mon, 27 Apr 2009 12:53:31 +0000 (14:53 +0200)
src/directoryplaylist.cpp

index 017e6ec96563c533d29e77d4ee533f9d05c4c1d5..a5d8c8ee8fa4c713d9a25d42b8fe304761849eca 100644 (file)
@@ -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;