From 463f4e95cff0e100b4c8c8b5378cfe1b2604c138 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 8 Sep 2019 11:49:28 +0000 Subject: fixed possible regressions git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@9068 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/fileloader.cpp | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'src/qmmpui/fileloader.cpp') diff --git a/src/qmmpui/fileloader.cpp b/src/qmmpui/fileloader.cpp index e4f557ac6..a03bb18c7 100644 --- a/src/qmmpui/fileloader.cpp +++ b/src/qmmpui/fileloader.cpp @@ -45,7 +45,7 @@ FileLoader::~FileLoader() QList FileLoader::processFile(const QString &path, QStringList *ignoredPaths) { QList tracks; - QList infoList = MetaDataManager::instance()->createPlayList(path, m_parts, ignoredPaths); + const QList infoList = MetaDataManager::instance()->createPlayList(path, m_parts, ignoredPaths); for(TrackInfo *info : qAsConst(infoList)) { @@ -132,27 +132,25 @@ void FileLoader::insertPlayList(const QString &path, PlayListItem *before) filters << QRegExp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); - for(PlayListTrack *t : qAsConst(tracks)) + QList::iterator it = tracks.begin(); + while(it != tracks.end()) { - if(t->path().contains("://")) + if((*it)->path().contains("://") && !protocols.contains((*it)->path().section("://", 0, 0))) { - if(!protocols.contains(t->path().section("://",0,0))) - { - tracks.removeAll(t); - delete t; - } + delete (*it); + it = tracks.erase(it); } - else if(!QFile::exists(t->path())) + else if(!QFile::exists((*it)->path())) { - tracks.removeAll(t); - delete t; + delete (*it); + it = tracks.erase(it); } else { bool found = false; for(const QRegExp &filter : qAsConst(filters)) { - if(filter.exactMatch(t->path())) + if(filter.exactMatch((*it)->path())) { found = true; break; @@ -160,8 +158,12 @@ void FileLoader::insertPlayList(const QString &path, PlayListItem *before) } if(!found) { - tracks.removeAll(t); - delete t; + delete (*it); + it = tracks.erase(it); + } + else + { + ++it; } } } @@ -384,12 +386,17 @@ void FileLoader::removeIgnoredTracks(QList *tracks, const QStri if(ignoredPaths.isEmpty()) return; - for(PlayListTrack *track : qAsConst(*tracks)) + QList::iterator it = tracks->begin(); + while(it != tracks->end()) { - if(ignoredPaths.contains(track->path())) + if(ignoredPaths.contains((*it)->path())) + { + delete (*it); + it = tracks->erase(it); + } + else { - tracks->removeAll(track); - delete track; + ++it; } } } -- cgit v1.2.3-13-gbd6f