[banshee] DbImportManager: fix out-of-sync collection while iterated (bgo#724635)



commit 347af1d4843cc5a844e7026ebd76da958d82bfbd
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Sat Mar 15 13:10:09 2014 +0100

    DbImportManager: fix out-of-sync collection while iterated (bgo#724635)
    
    As reported in the stacktrace of bug 724635, it could happen that
    while syncing an iPod, the NotifyAllSources() method could crash
    at some iteration of its foreach loop because the collection being
    iterated had been modified since the loop started.
    
    By making a copy of the collection before iterating, we avoid this
    potential problem.

 .../DatabaseImportManager.cs                       |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs 
b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
index 6abe6aa..9a24a9e 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
@@ -254,7 +254,8 @@ namespace Banshee.Collection.Database
 
         public void NotifyAllSources ()
         {
-            foreach (long primary_source_id in counts.Keys) {
+            var all_primary_source_ids = new List<long> (counts.Keys);
+            foreach (long primary_source_id in all_primary_source_ids) {
                 PrimarySource.GetById (primary_source_id).NotifyTracksAdded ();
             }
             counts.Clear ();


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