[banshee] DatabaseSource: fix crash at Rating sync (bgo#727030)



commit a74b354c4ad19851aafff06dcf4204f9368b576c
Author: Dmitriy Petukhov <dimart sp gmail com>
Date:   Thu Mar 27 12:19:38 2014 +0100

    DatabaseSource: fix crash at Rating sync (bgo#727030)
    
    OnTracksChanged() was iterating the PrimarySources collection,
    and on each iteration there could exist the possibility of making
    the ServiceManager.SourceManager.Sources collection change (and
    PrimarySources is a sub-set of this collection), for example:
    a new rating of 5 stars is set on a track, which makes the
    "Favorites" smart playlist appear (it could be invisible because
    of being empty before).
    
    Even if the super-set of a collection changes without making the
    sub-set change, its enumerator would see it "dirty" (out of sync)
    which would cause an exception, and make Banshee crash. The
    solution to this is make a copy of the PrimarySources sub-set
    before iterating it.
    
    Signed-off-by: Andrés G. Aragoneses <knocte gmail com>

 .../Banshee.Sources/DatabaseSource.cs              |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs 
b/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
index 64622b6..12c0514 100644
--- a/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
+++ b/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
@@ -572,7 +572,7 @@ namespace Banshee.Sources
         protected virtual void OnTracksChanged (params QueryField [] fields)
         {
             HandleTracksChanged (this, new TrackEventArgs (fields));
-            foreach (PrimarySource psource in PrimarySources) {
+            foreach (PrimarySource psource in PrimarySources.ToArray ()) {
                 psource.NotifyTracksChanged (fields);
             }
         }


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