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



commit 1d720ff8a44cbca4a13306c6b9389e3f36d4c5a9
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 8b86739..88e5a42 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
@@ -348,7 +348,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 8f6b748..6facadd 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 02492d5..196fa86 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
@@ -104,7 +104,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]