[banshee] [SourceManager] Handle exceptions in SourceAdded (bgo#612407)
- From: Alexander Kojevnikov <alexk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [SourceManager] Handle exceptions in SourceAdded (bgo#612407)
- Date: Thu, 25 Mar 2010 02:57:57 +0000 (UTC)
commit 803d729bd488322dbef6d958dacb9a1e9cda51ef
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date: Thu Mar 25 13:56:10 2010 +1100
[SourceManager] Handle exceptions in SourceAdded (bgo#612407)
.../Banshee.Sources/SourceManager.cs | 11 +++------
src/Libraries/Hyena/Hyena/EventArgs.cs | 21 +++++++++++++++++++-
2 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs b/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
index 94a3701..c430b05 100644
--- a/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
+++ b/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
@@ -154,13 +154,10 @@ namespace Banshee.Sources
source.ChildSourceAdded += OnChildSourceAdded;
source.ChildSourceRemoved += OnChildSourceRemoved;
- SourceAddedHandler handler = SourceAdded;
- if(handler != null) {
- SourceAddedArgs args = new SourceAddedArgs();
- args.Position = position;
- args.Source = source;
- handler(args);
- }
+ SourceAdded.SafeInvoke (new SourceAddedArgs () {
+ Position = position,
+ Source = source
+ });
if (source is MusicLibrarySource) {
music_library = source as MusicLibrarySource;
diff --git a/src/Libraries/Hyena/Hyena/EventArgs.cs b/src/Libraries/Hyena/Hyena/EventArgs.cs
index 7603a9c..7ac9ccc 100644
--- a/src/Libraries/Hyena/Hyena/EventArgs.cs
+++ b/src/Libraries/Hyena/Hyena/EventArgs.cs
@@ -4,7 +4,7 @@
// Author:
// Alexander Kojevnikov <alexander kojevnikov com>
//
-// Copyright (C) 2009 Alexander Kojevnikov
+// Copyright (C) 2009-2010 Alexander Kojevnikov
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,6 +26,8 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace Hyena
{
public class EventArgs<T> : System.EventArgs
@@ -41,4 +43,21 @@ namespace Hyena
get { return value; }
}
}
+
+ public static class EventExtensions
+ {
+ public static void SafeInvoke<T> (this T @event, params object[] args) where T : class
+ {
+ var multicast = @event as MulticastDelegate;
+ if (multicast != null) {
+ foreach (var handler in multicast.GetInvocationList ()) {
+ try {
+ handler.DynamicInvoke (args);
+ } catch (Exception e) {
+ Log.Exception (e);
+ }
+ }
+ }
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]