[banshee] Dap: fix several issues with the Disconnect operation (bgo#724656)



commit bfb3b817ca26d34370b09fff44fbc2d681d4c323
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Tue Feb 18 16:39:53 2014 +0100

    Dap: fix several issues with the Disconnect operation (bgo#724656)
    
    DapInfoBar was not being destroyed on the main thread, which
    could lead to crashes (I've seen some platforms more prone
    to crash with this than others). Fixing this exposed other
    synchronization issues, such as not checking for null in the
    same thread as the one doing the operation on a widget, and
    looping over a collection which could be modified, in which
    case we need to make a copy of it before iterating.

 .../Banshee.Sources.Gui/SourceView.cs              |    2 +-
 src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs  |    6 +++---
 src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs       |    3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs 
b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
index 0b52d0b..425547a 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
@@ -347,7 +347,7 @@ namespace Banshee.Sources.Gui
                 // Resort the tree store. This is performed in an event handler
                 // known not to conflict with gtk_tree_view_bin_expose() to prevent
                 // errors about corrupting the TreeView's internal state.
-                foreach (Source dsource in ServiceManager.SourceManager.Sources) {
+                foreach (Source dsource in ServiceManager.SourceManager.Sources.ToArray ()) {
                     TreeIter iter = store.FindSource (dsource);
                     if (!TreeIter.Zero.Equals (iter) &&
                         (int)store.GetValue (iter, (int)SourceModel.Columns.Order) != dsource.Order)
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs 
b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
index 061c0da..3b2e1f1 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapInfoBar.cs
@@ -106,11 +106,11 @@ namespace Banshee.Dap.Gui
 
         private void OnSourceUpdated (object o, EventArgs args)
         {
-            if (source.Sync.Syncing)
-                return;
-
             ThreadAssist.ProxyToMain (delegate {
                 try {
+                    if (source == null || source.Sync.Syncing) {
+                        return;
+                    }
                     UpdateUsage ();
                 } catch (Exception e) {
                     Hyena.Log.Exception (e);
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
index cd89f14..e3b1b8d 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
@@ -111,7 +111,8 @@ namespace Banshee.Dap
             PurgeTracks ();
 
             if (dap_info_bar != null) {
-                dap_info_bar.Destroy ();
+                var info_bar = dap_info_bar;
+                ThreadAssist.ProxyToMain (info_bar.Destroy);
                 dap_info_bar = null;
             }
 


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