[banshee] [Last.fm] Fix crash (bgo#613276)
- From: Alexander Kojevnikov <alexk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Last.fm] Fix crash (bgo#613276)
- Date: Fri, 19 Mar 2010 00:12:13 +0000 (UTC)
commit 0eb6e968b5153ddd90ea6f6ed5eb634886acab5f
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date: Fri Mar 19 11:11:52 2010 +1100
[Last.fm] Fix crash (bgo#613276)
.../AudioscrobblerService.cs | 11 ++++++++---
.../Banshee.Lastfm.Radio/LastfmSource.cs | 11 +++++++----
2 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
index 44ceed0..098c148 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Audioscrobbler/AudioscrobblerService.cs
@@ -96,9 +96,7 @@ namespace Banshee.Lastfm.Audioscrobbler
Network network = ServiceManager.Get<Network> ();
connection.UpdateNetworkState (network.Connected);
- network.StateChanged += delegate (object o, NetworkStateChangedArgs args) {
- connection.UpdateNetworkState (args.Connected);
- };
+ network.StateChanged += HandleNetworkStateChanged;
// Update the Visit action menu item if we update our account info
LastfmCore.Account.Updated += delegate (object o, EventArgs args) {
@@ -152,6 +150,8 @@ namespace Banshee.Lastfm.Audioscrobbler
ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+ ServiceManager.Get<Network> ().StateChanged -= HandleNetworkStateChanged;
+
// When we stop the connection, queue ends up getting saved too, so the
// track we queued earlier should stay until next session.
connection.Stop ();
@@ -161,6 +161,11 @@ namespace Banshee.Lastfm.Audioscrobbler
actions = null;
}
+ private void HandleNetworkStateChanged (object o, NetworkStateChangedArgs args)
+ {
+ connection.UpdateNetworkState (args.Connected);
+ }
+
// We need to time how long the song has played
internal class SongTimer
{
diff --git a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
index a78385d..1e636b4 100644
--- a/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
+++ b/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
@@ -92,10 +92,7 @@ namespace Banshee.Lastfm.Radio
connection = LastfmCore.Radio;
Network network = ServiceManager.Get<Network> ();
connection.UpdateNetworkState (network.Connected);
- network.StateChanged += delegate (object o, NetworkStateChangedArgs args) {
- connection.UpdateNetworkState (args.Connected);
- };
-
+ network.StateChanged += HandleNetworkStateChanged;
Connection.StateChanged += HandleConnectionStateChanged;
UpdateUI ();
@@ -126,6 +123,7 @@ namespace Banshee.Lastfm.Radio
{
ServiceManager.Get<DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
Connection.StateChanged -= HandleConnectionStateChanged;
+ ServiceManager.Get<Network> ().StateChanged -= HandleNetworkStateChanged;
Connection.Dispose ();
UninstallPreferences ();
actions.Dispose ();
@@ -217,6 +215,11 @@ namespace Banshee.Lastfm.Radio
get { return false; }
}
+ private void HandleNetworkStateChanged (object o, NetworkStateChangedArgs args)
+ {
+ connection.UpdateNetworkState (args.Connected);
+ }
+
private void HandleConnectionStateChanged (object sender, ConnectionStateChangedArgs args)
{
UpdateUI ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]