[banshee] [TrackEditor] Prevent UpdateMetadata() to be called too many times



commit 13af29b04e0bfc8b54509dfdf7569e88087e05bc
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Tue Sep 28 14:26:25 2010 +0200

    [TrackEditor] Prevent UpdateMetadata() to be called too many times
    
    The patches committed for BGO#589196 so far caused that the
    UpdateMetadata virtual call happened way too many times when
    dealing with DatabaseTrackInfo objects, when it's actually not
    needed and could even cause an exception in IpodTrackInfo
    ("Shouldn't update an IpodTrackInfo from an IpodTrackInfo")
    that could break sync in some circumstances (and maybe also
    device sync with the AppleDevice extension).
    
    Signed-off-by: Alan McGovern <alan mcgovern gmail com>

 .../Banshee.Core/Banshee.Collection/TrackInfo.cs   |    5 +++++
 .../DatabaseTrackInfo.cs                           |    8 ++++++--
 .../Banshee.Gui.TrackEditor/TrackEditorDialog.cs   |    2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
index a2f3e91..8ecefc7 100644
--- a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
+++ b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
@@ -133,6 +133,11 @@ namespace Banshee.Collection
         {
         }
 
+        public virtual void Update ()
+        {
+            Save ();
+        }
+
         public virtual void UpdateLastPlayed ()
         {
             LastPlayed = DateTime.Now;
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
index 9761fcb..f83a441 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
@@ -168,6 +168,12 @@ namespace Banshee.Collection.Database
             Save (NotifySaved);
         }
 
+        public override void Update ()
+        {
+            PrimarySource.UpdateMetadata (this);
+            base.Update ();
+        }
+
         public override void UpdateLastPlayed ()
         {
             Refresh ();
@@ -177,8 +183,6 @@ namespace Banshee.Collection.Database
 
         public void Save (bool notify, params QueryField [] fields_changed)
         {
-            PrimarySource.UpdateMetadata (this);
-
             // If either the artist or album changed,
             if (ArtistId == 0 || AlbumId == 0 || artist_changed == true || album_changed == true) {
                 DatabaseArtistInfo artist = Artist;
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
index 1954638..22dcc3a 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
@@ -614,7 +614,7 @@ namespace Banshee.Gui.TrackEditor
         private void SaveTrack (EditorTrackInfo track)
         {
             TrackInfo.ExportableMerge (track, track.SourceTrack);
-            track.SourceTrack.Save ();
+            track.SourceTrack.Update ();
 
             if (track.SourceTrack.TrackEqual (ServiceManager.PlayerEngine.CurrentTrack)) {
                 TrackInfo.ExportableMerge (track, ServiceManager.PlayerEngine.CurrentTrack);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]