[banshee] [PlayQueue] Workaround bad startup crash on old Mono



commit ee5f2b64e0541d70414df2be295e359078a74eb9
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Mar 16 16:57:33 2010 -0700

    [PlayQueue] Workaround bad startup crash on old Mono
    
    Handling a ComboBox.Changed event with an anonymous delegate was causing
    a crash for users on older versions of Mono (bgo#612631)

 .../Banshee.Widgets/DictionaryComboBox.cs          |    9 +++++-
 .../Banshee.PlayQueue/HeaderWidget.cs              |   28 +++++++++++--------
 2 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
index faa5052..8e034a3 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/DictionaryComboBox.cs
@@ -122,7 +122,14 @@ namespace Banshee.Widgets
 
                 return default (T);
             }
-            set { SetActiveIter (IterFor (value)); }
+            set {
+                var iter = IterFor (value);
+                if (TreeIter.Zero.Equals (iter)) {
+                    Hyena.Log.WarningFormat ("Cannot set ActiveValue to {0}, its TreeIter is null", value);
+                } else {
+                    SetActiveIter (iter);
+                }
+            }
         }
     }
 }
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs
index adba02d..4eb9d87 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/HeaderWidget.cs
@@ -53,6 +53,7 @@ namespace Banshee.PlayQueue
 
         public HeaderWidget (Shuffler shuffler, string shuffle_mode_id, string source_name) : base ()
         {
+            ThreadAssist.AssertInMainThread ();
             this.Spacing = 6;
 
             var fill_label = new Label (Catalog.GetString ("_Fill"));
@@ -65,17 +66,7 @@ namespace Banshee.PlayQueue
             }
 
             fill_label.MnemonicWidget = mode_combo;
-            mode_combo.Changed += delegate {
-                var random_by = mode_combo.ActiveValue;
-                foreach (var widget in sensitive_widgets) {
-                    widget.Sensitive = random_by.Id != "off";
-                }
-
-                var handler = ModeChanged;
-                if (handler != null) {
-                    handler (this, new EventArgs<RandomBy> (random_by));
-                }
-            };
+            mode_combo.Changed += OnModeComboChanged;
 
             var from_label = new Label (Catalog.GetString ("f_rom"));
             var source_combo_box = new QueueableSourceComboBox (source_name);
@@ -100,12 +91,25 @@ namespace Banshee.PlayQueue
             var default_randomby = shuffler.RandomModes.FirstOrDefault (r => r.Id == shuffle_mode_id);
             if (default_randomby != null) {
                 mode_combo.ActiveValue = default_randomby;
-            } else {
+            } else if (mode_combo.Default != null) {
                 mode_combo.ActiveValue = mode_combo.Default;
             }
 
             shuffler.RandomModeAdded   += (r) => mode_combo.Add (r.Adverb, r);
             shuffler.RandomModeRemoved += (r) => mode_combo.Remove (r);
         }
+
+        private void OnModeComboChanged (object o, EventArgs args)
+        {
+            var random_by = mode_combo.ActiveValue;
+            foreach (var widget in sensitive_widgets) {
+                widget.Sensitive = random_by.Id != "off";
+            }
+
+            var handler = ModeChanged;
+            if (handler != null) {
+                handler (this, new EventArgs<RandomBy> (random_by));
+            }
+        }
     }
 }



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