Commit cb3674aa authored by Matěj Laitl's avatar Matěj Laitl
Browse files

SqlPlaylist: don't observe track and re-save whole playlist on track change

No other playlist does that and this causes problems when someone has
really big playlists and slow connection to external MySQL db.

Not updating track metadata should not hurt, these are immediately
replaced by real ones by MetaProxy::Track. Moreover for uidUrl updates
there is SqlTrack::updatePlaylistsToDb() (I don't however know whether
it works as expected). Acked by Bart on the bug.

BUG: 301700
FIXED-IN: 2.6
parent 58dd0be7
......@@ -4,6 +4,7 @@ Amarok ChangeLog
VERSION 2.6
CHANGES:
* Prevent lags with large Saved playlists. (BR 301700)
* Increase minimal required ffmpeg version up to 0.7.
* Use audio-x-generic icon for bit rate, not a generic one. (BR 302753)
* Add Amarok.Playlist.playMediaList() script bindings for API symmetry.
......
......@@ -250,7 +250,6 @@ SqlPlaylist::addTrack( Meta::TrackPtr track, int position )
position = m_tracks.count();
else
position = qMin( position, m_tracks.count() );
subscribeTo( track ); //keep track of metadata changes.
m_tracks.insert( position, track );
saveToDb( true );
notifyObserversTrackAdded( track, position );
......@@ -265,31 +264,10 @@ SqlPlaylist::removeTrack( int position )
if( position < 0 || position >= m_tracks.size() )
return;
Meta::TrackPtr track = m_tracks.takeAt( position );
unsubscribeFrom( track );
saveToDb( true );
notifyObserversTrackRemoved( position );
}
void
SqlPlaylist::metadataChanged( Meta::TrackPtr track )
{
//TODO: do we really need to observe track changes? Metadata will be properly saved
//on exit and proxy tracks are loaded with uidUrl. So at worse the save metadata in
//playlist_tracks will be outdated until real track is loaded.
if( !m_tracksLoaded )
loadTracks();
//When AFT detects a moved file it will update the track and make it signal it's observers.
if( !m_tracks.contains( track ) )
{
error() << "Got a metadataChanged for a track that is not in the playlist.";
return;
}
//force update of tracks in database
saveToDb();
}
void
SqlPlaylist::loadTracks()
{
......@@ -312,8 +290,6 @@ SqlPlaylist::loadTracks()
proxyTrack->setAlbum( row[4] );
proxyTrack->setArtist( row[5] );
Meta::TrackPtr trackPtr = Meta::TrackPtr( proxyTrack );
//subscribed to force a save to db on any change (such as AFT file move)
subscribeTo( trackPtr );
m_tracks << trackPtr;
}
......
......@@ -36,7 +36,7 @@ typedef QList<SqlPlaylistGroupPtr> SqlPlaylistGroupList;
@author Nikolaj Hald Nielsen <nhn@kde.org>
*/
class SqlPlaylist : public Playlist, public Meta::Observer
class SqlPlaylist : public Playlist
{
public:
SqlPlaylist( const QString &name, const Meta::TrackList &tracks,
......@@ -66,14 +66,6 @@ class SqlPlaylist : public Playlist, public Meta::Observer
virtual void addTrack( Meta::TrackPtr track, int position = -1 );
virtual void removeTrack( int position );
/* Meta::Observer methods */
virtual void metadataChanged( Meta::TrackPtr track );
virtual void metadataChanged( Meta::ArtistPtr artist ) { Q_UNUSED( artist ) }
virtual void metadataChanged( Meta::AlbumPtr album ) { Q_UNUSED( album ) }
virtual void metadataChanged( Meta::GenrePtr genre ) { Q_UNUSED( genre ) }
virtual void metadataChanged( Meta::ComposerPtr composer ) { Q_UNUSED( composer ) }
virtual void metadataChanged( Meta::YearPtr year ) { Q_UNUSED( year ) }
// SqlPlaylist-specific methods
bool saveToDb( bool tracks = true );
void removeFromDb();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment