[banshee] [MeeGo] Fix a race between panel ready and banshee



commit 6d36af307039a80ced7d9be250758352792cedbb
Author: Aaron Bockover <abockover novell com>
Date:   Mon Mar 22 21:40:38 2010 -0400

    [MeeGo] Fix a race between panel ready and banshee
    
    We create the panel UI when mutter-moblin raises the Ready event,
    but this may be raised before Banshee has started all the required
    services, and the opposite may be true. So deal with this.

 .../Banshee.MeeGo/Banshee.MeeGo/MeeGoPanel.cs      |   12 +++++++++---
 .../Banshee.MeeGo/Banshee.MeeGo/MeeGoService.cs    |    7 ++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoPanel.cs b/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoPanel.cs
index cee7659..44bab20 100644
--- a/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoPanel.cs
+++ b/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoPanel.cs
@@ -42,6 +42,7 @@ namespace Banshee.MeeGo
         public uint ToolbarPanelWidth { get; private set; }
         public uint ToolbarPanelHeight { get; private set; }
         public MediaPanelContents Contents { get; private set; }
+        public bool BansheeIsInitialized { get; set; }
 
         public MeeGoPanel ()
         {
@@ -64,9 +65,14 @@ namespace Banshee.MeeGo
             try {
                 ToolbarPanel = new PanelGtk ("banshee", "media", null, "media-button", true);
                 ToolbarPanel.ReadyEvent += (o, e) => {
-                    Contents = new MediaPanelContents ();
-                    Contents.ShowAll ();
-                    ToolbarPanel.SetChild (Contents);
+                    lock (this) {
+                        Contents = new MediaPanelContents ();
+                        Contents.ShowAll ();
+                        ToolbarPanel.SetChild (Contents);
+                        if (BansheeIsInitialized) {
+                            Contents.BuildViews ();
+                        }
+                    }
                 };
             } catch (Exception e) {
                 Log.Exception ("Could not bind to MeeGo panel", e);
diff --git a/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoService.cs b/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoService.cs
index eea39eb..cc47c54 100644
--- a/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoService.cs
+++ b/src/Extensions/Banshee.MeeGo/Banshee.MeeGo/MeeGoService.cs
@@ -110,7 +110,12 @@ namespace Banshee.MeeGo
                 return;
             }
 
-            MeeGoPanel.Instance.Contents.BuildViews ();
+            lock (MeeGoPanel.Instance) {
+                MeeGoPanel.Instance.BansheeIsInitialized = true;
+                if (MeeGoPanel.Instance.Contents != null) {
+                    MeeGoPanel.Instance.Contents.BuildViews ();
+                }
+            }
 
             elements_service.PrimaryWindowClose = () => {
                 elements_service.PrimaryWindow.Hide ();



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