From kde-commits Mon Jun 01 02:57:24 2015 From: Soren Harward Date: Mon, 01 Jun 2015 02:57:24 +0000 To: kde-commits Subject: [amarok] /: Fix long-standing bug: APG returns empty playlist Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=143312745604656 Git commit 0b7492e709d9c8c37e8d9e74f549d0073b775b19 by Soren Harward. Committed on 01/06/2015 at 02:53. Pushed by stharward into branch 'master'. Fix long-standing bug: APG returns empty playlist Well, that was dumb. Added a sanity check where if the suggested playlist size is 0 (which means "I don't really care what the playlist size is"), then just go with whatever the non-zero size from the previous iteration was. BUG: 313762 BUG: 315206 BUG: 323945 FIXED-IN: 2.9 M +2 -0 ChangeLog M +2 -1 src/playlistgenerator/ConstraintSolver.cpp http://commits.kde.org/amarok/0b7492e709d9c8c37e8d9e74f549d0073b775b19 diff --git a/ChangeLog b/ChangeLog index 58c745e..2cce0f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,8 @@ VERSION 2.8.90 compilers currently supported by KDE. = BUGFIXES: + * Fixed longstanding APG zero-length playlist bug (BR 313762, BR 315206, + BR 323945) * Fix a crash when searching the Icecast directory. (BR 334479) * Correct wrong lowercase for FLAC and MP3. Patch provided by Duilio Fe= lix (BR 339495) * Collection Browser no longer excessively expands the tree. (BR 300557) diff --git a/src/playlistgenerator/ConstraintSolver.cpp b/src/playlistgener= ator/ConstraintSolver.cpp index 56838dc..ba58a9c 100644 --- a/src/playlistgenerator/ConstraintSolver.cpp +++ b/src/playlistgenerator/ConstraintSolver.cpp @@ -159,7 +159,8 @@ APG::ConstraintSolver::run() quint32 generation =3D 0; Meta::TrackList* best =3D NULL; while ( !m_abortRequested && ( generation < m_maxGenerations ) ) { - m_suggestedPlaylistSize =3D m_constraintTreeRoot->suggestPlaylistS= ize(); + quint32 s =3D m_constraintTreeRoot->suggestPlaylistSize(); + m_suggestedPlaylistSize =3D (s > 0) ? s : m_suggestedPlaylistSize; fill_population( population ); best =3D find_best( population ); if ( population.value( best ) < m_satisfactionThreshold ) {