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

index 017e6ec..a5d8c8e 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;