banshee r3843 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Sources src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Libraries/Lastfm/Lastfm



Author: gburt
Date: Tue Apr 29 17:24:51 2008
New Revision: 3843
URL: http://svn.gnome.org/viewvc/banshee?rev=3843&view=rev

Log:
2008-04-29  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Services/Banshee.Sources/Source.cs: Be more careful
	with unregistering handlers to status message events.

	* src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedMessageBar.cs:
	Fix memory leak/cpu usage seen after selecting a Last.fm source, caused by
	AnimatedImage's stage continuing to play after the status message should
	have been hidden/removed.  Its still strange that while the AnimatedImage
	is shown/animating it triggers so many ExposeEvents on the ListView, but
	at least they stop once the status message goes away.  Fixes BGO #523646.

	* src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs: Explicitly mark
	private members as private.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedMessageBar.cs
   trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/Source.cs	Tue Apr 29 17:24:51 2008
@@ -243,28 +243,32 @@
 
         protected virtual void SetStatus (string message, bool can_close, bool is_spinning, string icon_name)
         {
-            if (status_message == null) {
-                status_message = new SourceMessage (this);
-                PushMessage (status_message);
-            }
-            
-            string status_name = String.Format ("<i>{0}</i>", GLib.Markup.EscapeText (Name));
-            
-            status_message.FreezeNotify ();
-            status_message.Text = String.Format (GLib.Markup.EscapeText (message), status_name);
-            status_message.CanClose = can_close;
-            status_message.IsSpinning = is_spinning;
-            status_message.SetIconName (icon_name);
-            status_message.ClearActions ();
+            lock (this) {
+                if (status_message == null) {
+                    status_message = new SourceMessage (this);
+                    PushMessage (status_message);
+                }
             
+                string status_name = String.Format ("<i>{0}</i>", GLib.Markup.EscapeText (Name));
+                
+                status_message.FreezeNotify ();
+                status_message.Text = String.Format (GLib.Markup.EscapeText (message), status_name);
+                status_message.CanClose = can_close;
+                status_message.IsSpinning = is_spinning;
+                status_message.SetIconName (icon_name);
+                status_message.ClearActions ();
+            }
+                
             status_message.ThawNotify ();
         }
 
         protected virtual void HideStatus ()
         {
-            if (status_message != null) {
-                RemoveMessage (status_message);
-                status_message = null;
+            lock (this) {
+                if (status_message != null) {
+                    RemoveMessage (status_message);
+                    status_message = null;
+                }
             }
         }
 
@@ -301,6 +305,9 @@
         {
             lock (this) {
                 if (messages.Count > 0) {
+                    foreach (SourceMessage message in messages) {
+                        message.Updated -= HandleMessageUpdated;
+                    }
                     messages.Clear ();
                     OnMessageNotify ();
                 }
@@ -349,6 +356,7 @@
         {
             lock (this) {
                 if (messages.Remove (message)) {
+                    message.Updated -= HandleMessageUpdated;
                     OnMessageNotify ();
                 }
             }   

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedMessageBar.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedMessageBar.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedMessageBar.cs	Tue Apr 29 17:24:51 2008
@@ -69,6 +69,9 @@
         
         private void ConnectSource (Source source)
         {
+            if (source == this.source)
+                return;
+
             this.source = source;
             
             if (this.source != null) {
@@ -85,6 +88,9 @@
         private void InnerUpdate (object o, EventArgs args)
         {
             if (source == null || source.CurrentMessage == null || source.CurrentMessage.IsHidden) {
+                // Fix bug where the AnimatedImage's stage kept playing, triggering tons of ExpoeEvents
+                // that caused the ListView to be re Exposed.
+                Spinning = false;
                 Hide ();
                 return;
             }

Modified: trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs
==============================================================================
--- trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs	(original)
+++ trunk/banshee/src/Libraries/Lastfm/Lastfm/AudioscrobblerConnection.cs	Tue Apr 29 17:24:51 2008
@@ -43,7 +43,7 @@
 {
     public class AudioscrobblerConnection
     {
-        enum State {
+        private enum State {
             Idle,
             NeedHandshake,
             NeedTransmit,
@@ -52,44 +52,44 @@
             WaitingForResponse
         };
 
-        const int TICK_INTERVAL = 2000; /* 2 seconds */
-        const int FAILURE_LOG_MINUTES = 5; /* 5 minute delay on logging failure to upload information */
-        const int RETRY_SECONDS = 60; /* 60 second delay for transmission retries */
-        const int MAX_RETRY_SECONDS = 7200; /* 2 hours, as defined in the last.fm protocol */
-        const int TIME_OUT = 5000; /* 5 seconds timeout for webrequests */
-        const string CLIENT_ID = "bsh";
-        const string CLIENT_VERSION = "0.1";
-        const string SCROBBLER_URL = "http://post.audioscrobbler.com/";;
-        const string SCROBBLER_VERSION = "1.2";
-
-        string post_url;
-        string session_id = null;
-        string now_playing_url;
+        private const int TICK_INTERVAL = 2000; /* 2 seconds */
+        private const int FAILURE_LOG_MINUTES = 5; /* 5 minute delay on logging failure to upload information */
+        private const int RETRY_SECONDS = 60; /* 60 second delay for transmission retries */
+        private const int MAX_RETRY_SECONDS = 7200; /* 2 hours, as defined in the last.fm protocol */
+        private const int TIME_OUT = 5000; /* 5 seconds timeout for webrequests */
+        private const string CLIENT_ID = "bsh";
+        private const string CLIENT_VERSION = "0.1";
+        private const string SCROBBLER_URL = "http://post.audioscrobbler.com/";;
+        private const string SCROBBLER_VERSION = "1.2";
+
+        private string post_url;
+        private string session_id = null;
+        private string now_playing_url;
         
-        bool connected = false; /* if we're connected to network or not */
+        private bool connected = false; /* if we're connected to network or not */
         public bool Connected {
             get { return connected; }
         }
         
-        bool started = false; /* engine has started and was/is connected to AS */
+        private bool started = false; /* engine has started and was/is connected to AS */
         public bool Started {
             get { return started; }
         }
 
-        System.Timers.Timer timer;
-        DateTime next_interval;
-        DateTime last_upload_failed_logged;
-
-        IQueue queue;
-        
-        int hard_failures = 0;
-        int hard_failure_retry_sec = 60;
-        
-        HttpWebRequest now_playing_post;
-        string current_now_playing_uri;
-        HttpWebRequest current_web_req;
-        IAsyncResult current_async_result;
-        State state;
+        private System.Timers.Timer timer;
+        private DateTime next_interval;
+        private DateTime last_upload_failed_logged;
+
+        private IQueue queue;
+        
+        private int hard_failures = 0;
+        private int hard_failure_retry_sec = 60;
+        
+        private HttpWebRequest now_playing_post;
+        private string current_now_playing_uri;
+        private HttpWebRequest current_web_req;
+        private IAsyncResult current_async_result;
+        private State state;
         
         internal AudioscrobblerConnection (IQueue queue)
         {



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