[banshee] Notifications: improve null check before AttachToWidget() (bgo#723889)
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Notifications: improve null check before AttachToWidget() (bgo#723889)
- Date: Sat, 8 Feb 2014 11:33:47 +0000 (UTC)
commit 1019bf49b3fcc72b8e16a3c6541d07a7d1fb6fd3
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Sat Feb 8 12:33:11 2014 +0100
Notifications: improve null check before AttachToWidget() (bgo#723889)
GtkNotificationArea class returns null always for its Widget property,
which means that every user of INotificationAreaBox should check if
it's null before dereferencing it, not only check if the object is
null.
This was not happening and was causing an apparently harmless warning
to be printed in the console. The warning didn't have enough info
about the exception so now the .Exception() method is used instead,
which prints the whole stacktrace. (This has been changed in
SoundMenuService as well, for consistency.)
This didn't seem to happen in the stable branch because in there the
class used as an INotificationAreaBox is X11NotificationAreaBox, which
seems to be deprecated in master. Nonetheless, this fix should be
backported too because X11NotificationAreaBox seemed to be only used
in the Linux platform, so by backporting it we may be fixing the
issue in other platforms.
.../NotificationAreaService.cs | 4 ++--
.../Notifications/Notification.cs | 4 ++++
.../Banshee.SoundMenu/SoundMenuService.cs | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
index d85acdc..7dbad55 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
@@ -484,7 +484,7 @@ namespace Banshee.NotificationArea
current_nf.Summary = current_track.DisplayTrackTitle;
current_nf.Body = message;
current_nf.IconName = Banshee.ServiceStack.Application.IconName;
- if (notif_area != null) {
+ if (notif_area != null && notif_area.Widget != null) {
current_nf.AttachToWidget (notif_area.Widget);
}
}
@@ -520,7 +520,7 @@ namespace Banshee.NotificationArea
current_nf.Show ();
} catch (Exception e) {
- Hyena.Log.Warning (Catalog.GetString ("Cannot show notification"), e.Message, false);
+ Hyena.Log.Exception (Catalog.GetString ("Cannot show notification"), e);
}
}
diff --git a/src/Extensions/Banshee.NotificationArea/Notifications/Notification.cs
b/src/Extensions/Banshee.NotificationArea/Notifications/Notification.cs
index 9b6eecc..9f46c99 100644
--- a/src/Extensions/Banshee.NotificationArea/Notifications/Notification.cs
+++ b/src/Extensions/Banshee.NotificationArea/Notifications/Notification.cs
@@ -262,6 +262,10 @@ namespace Notifications {
}
public void AttachToWidget (Gtk.Widget widget) {
+ if (widget == null) {
+ throw new ArgumentNullException ("widget");
+ }
+
int x, y;
widget.Window.GetOrigin (out x, out y);
diff --git a/src/Extensions/Banshee.SoundMenu/Banshee.SoundMenu/SoundMenuService.cs
b/src/Extensions/Banshee.SoundMenu/Banshee.SoundMenu/SoundMenuService.cs
index 2b971a1..8796ed4 100644
--- a/src/Extensions/Banshee.SoundMenu/Banshee.SoundMenu/SoundMenuService.cs
+++ b/src/Extensions/Banshee.SoundMenu/Banshee.SoundMenu/SoundMenuService.cs
@@ -328,7 +328,7 @@ namespace Banshee.SoundMenu
current_nf.Show ();
} catch (Exception e) {
- Log.Warning ("Cannot show notification", e.Message, false);
+ Log.Exception ("Cannot show notification", e);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]