From kde-commits Thu Jan 26 02:24:38 2012 From: Michael Pyne Date: Thu, 26 Jan 2012 02:24:38 +0000 To: kde-commits Subject: KDE/kdemultimedia/juk Message-Id: <20120126022438.32E47AC892 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=132754486513944 SVN commit 1275917 by mpyne: Don't load a playlist if it's already found by folder scan. The way file scanning is performed, it's possible for a playlist that is stored with a .m3u file to be found and loaded before JuK has finished loading its cached playlists. There's a few ways to fix this, but the most conservative (especially for those dealing with this bug for awhile) is to filter playlists as they are being loaded from the cache and remove any that have already been loaded. This also does not require a change to the QDataStream binary format used for saving playlists. This should fix a bug that's been open for more than five years now... by the way, anyone want to help with finding/fixing more JuK bugs? :D BUG:113769 M +8 -0 cache.cpp M +9 -1 playlistcollection.h --- trunk/KDE/kdemultimedia/juk/cache.cpp #1275916:1275917 @@ -200,6 +200,14 @@ Playlist *p = new Playlist(collection, true); createdPlaylists.append(p); s >> *p; + + // We may have already read this playlist from the folder + // scanner, if an .m3u playlist + if(collection->containsPlaylistFile(p->fileName())) { + delete p; + p = 0; + } + playlist = p; break; } // switch --- trunk/KDE/kdemultimedia/juk/playlistcollection.h #1275916:1275917 @@ -152,6 +152,15 @@ virtual void raise(Playlist *playlist); /** + * @return true, if a playlist with the file name given in @p file is + * already loaded into this collection, or false otherwise. + * + * @note @p file should be the "canonical" full path to the file to avoid + * problems with duplicates and symlinks. + */ + bool containsPlaylistFile(const QString &file) const; + + /** * This is used to put up a temporary widget over the top of the playlist * stack. This is part of a trick to significantly speed up painting by * hiding the playlist to which items are being added. @@ -167,7 +176,6 @@ virtual void removePlaylist(Playlist *playlist) = 0; bool importPlaylists() const; - bool containsPlaylistFile(const QString &file) const; QString playlistNameDialog(const QString &caption = i18n("Create New Playlist"), const QString &suggest = QString(),