Bug 132447 - songs are removed from the playlist when dynamic playlist upcoming tracks count is reduced
Summary: songs are removed from the playlist when dynamic playlist upcoming tracks cou...
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
: 140449 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-15 14:46 UTC by richlv
Modified: 2007-01-23 10:41 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description richlv 2006-08-15 14:46:52 UTC
Version:           svn (using KDE KDE 3.5.4)
Installed from:    Slackware Packages
OS:                Linux

load a dynamic playlist, populate it.
add a couple more songs, reduce "upcoming tracks" in dynamic playlist properties.
last track from the playlist are removed.

reducing upcoming tracks should not remove currently added tracks from the playlist.
Comment 1 Seb Ruiz 2006-08-15 15:56:15 UTC
why not?
Comment 2 richlv 2006-08-15 16:07:20 UTC
existing songs in the playlist are not removed when a dynamic playlist is loaded, currently even new songs are added if existing upcoming tracks are more than configured (this i would like to see changed, but that is a different issue).

now, if a user has a dynamic playlist, but would like to reduce the amount at which new songs are added, reducing this parameter in options seems a logical choice. i would expect amarok to stop adding new tracks until upcoming tracks are less than the parameter (which it currently does not ;) ), but removal of already existing sonfs seems very counterintuitive.

that is, i am reducing the count for upcoming songs to be _added_, which should not affect already existing tracks.
Comment 3 Seb Ruiz 2006-11-13 11:28:49 UTC
SVN commit 604569 by seb:

* Don't remove tracks from the playlist when reducing the upcoming count of the current dynamic mode
* Only append tracks to the playlist if the playlist track count is greater than dynamic mode upcoming count
BUG: 132447
BUG: 124440


 M  +13 -29    playlist.cpp  


--- trunk/extragear/multimedia/amarok/src/playlist.cpp #604568:604569
@@ -617,8 +617,6 @@
 void
 Playlist::adjustDynamicUpcoming( bool saveUndo )
 {
-    int  x = 0;
-
     /**
      *  If m_currentTrack exists, we iterate until we find it
      *  Else, we iterate until we find an item which is enabled
@@ -636,36 +634,16 @@
     if( m_currentTrack )
         ++it;
 
-
+    int  x = 0;
     for ( ; *it && x < dynamicMode()->upcomingCount() ; ++it, ++x );
 
     if ( x < dynamicMode()->upcomingCount() )
     {
         addDynamicModeTracks( dynamicMode()->upcomingCount() - x );
     }
-    else
-    {
-        if( isLocked() ) return;
 
-        //assemble a list of what needs removing
-        //calling removeItem() iteratively is more efficient if they are in _reverse_ order, hence the prepend()
-        QPtrList<QListViewItem> list;
-        for ( ; *it ; ++it ) {
-            list.append( it.current() );
-        }
-
-        if( list.isEmpty() ) return;
-        if( saveUndo )
-            saveUndoState();
-
-        //remove the items
-        for( QListViewItem *item = list.last(); item; item = list.prev() )
-        {
-            removeItem( static_cast<PlaylistItem*>( item ) );
-            delete item;
-        }
-        //NOTE no need to emit childCountChanged(), removeItem() does that for us
-    }
+    if( saveUndo )
+        saveUndoState();
 }
 
 /**
@@ -1212,13 +1190,15 @@
     MyIterator it( this, MyIterator::Visible );
     if( !item ) item = currentTrack();
 
-    for( int x=0 ; *it; ++it, x++ )
+    int x = 0;
+    for( ; *it; ++it, x++ )
     {
         if( *it == item )
         {
             for ( PlaylistItem *first = firstChild();
                   dynamicMode()->cycleTracks() && x >= dynamicMode()->previousCount() && first;
-                  first = firstChild(), x-- ) {
+                  first = firstChild(), x-- )
+            {
                 removeItem( first ); //first visible item
                 delete first;
             }
@@ -1226,9 +1206,13 @@
         }
     }
 
-    //Just starting to play from stopped, don't append something needlessely
-    bool dontAppend = EngineController::instance()->engine()->state() == Engine::Empty;
+    const int upcomingTracks = childCount() - x;
 
+    // Just starting to play from stopped, don't append something needlessely
+    // or, we have more than enough items in the queue.
+    bool dontAppend = ( EngineController::instance()->engine()->state() == Engine::Empty ) ||
+                        upcomingTracks >= dynamicMode()->upcomingCount();
+
     //keep upcomingTracks requirement, this seems to break StopAfterCurrent
     if( !dontAppend && m_stopAfterTrack != m_currentTrack )
     {
Comment 4 richlv 2006-11-14 09:43:35 UTC
fix confirmed in revision 604744
Comment 5 Bram Schoenmakers 2007-01-23 10:41:48 UTC
*** Bug 140449 has been marked as a duplicate of this bug. ***