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



commit 85ddf275da9a89363f5ce6517484f2981f8f06af
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Sat Mar 15 13:27:30 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.
    
    (Backported manually from master branch, as it could not be simply
    cherry-picked, because it would break the build.)

 .../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 5500dbd..c41af85 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
@@ -251,7 +251,8 @@ namespace Banshee.Collection.Database
 
         public void NotifyAllSources ()
         {
-            foreach (int primary_source_id in counts.Keys) {
+            var all_primary_source_ids = new List<int> (counts.Keys);
+            foreach (int 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]