After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 645222 - The Notify GI can't work because of constructor
The Notify GI can't work because of constructor
Status: RESOLVED FIXED
Product: libnotify
Classification: Platform
Component: general
git master
Other Linux
: Normal critical
: ---
Assigned To: William Jon McCann
Depends on:
Blocks:
 
 
Reported: 2011-03-19 13:28 UTC by tualatrix
Modified: 2011-03-21 03:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
don't assert if summary is not set, return gerror instead (1.51 KB, patch)
2011-03-20 17:10 UTC, johnp
none Details | Review

Description tualatrix 2011-03-19 13:28:14 UTC
In Notify, if I construct the Notification with summary, body, icon_name and id, "body" and "icon_name" will fail. But there's no problem if I set them explicitly.

The command:

$ python -c "from gi.repository import Notify;Notify.init('test');n=Notify.Notification(summary='summary',body='body',icon_name='gedit',id=1);print n.get_property('summary'),n.get_property('body'),n.get_property('icon_name'),n.get_property('id')"

The output (the body and icon_name failed):

(process:30826): libnotify-CRITICAL **: notify_notification_update: assertion `summary != NULL && *summary != '\0'' failed

(process:30826): libnotify-CRITICAL **: notify_notification_update: assertion `summary != NULL && *summary != '\0'' failed
summary None None 1


This command which set properties explicitly works.

$ python -c "from gi.repository import Notify;Notify.init('test');n=Notify.Notification(summary='summary',id=1);n.set_property('body','body');n.set_property('icon_name','gedit');print n.get_property('summary'),n.get_property('body'),n.get_property('icon_name'),n.get_property('id')"

The output:

summary body gedit 1


Here's another problem:

The "summary" is a required parameter, but I can still construct the like this: n=Notify.Notification()

Please fix this problem. Thanks.
Comment 1 tualatrix 2011-03-19 13:34:26 UTC
And it works if you call the Notification constructor:

$ python -c "from gi.repository import Notify;Notify.init('test');n=Notify.Notification.new('summary', 'body', 'gedit');print n.get_property('summary'),n.get_property('body'),n.get_property('icon_name'),n.get_property('id')"
summary body gedit 0
Comment 2 johnp 2011-03-20 16:42:51 UTC
(In reply to comment #0)

> 
> Here's another problem:
> 
> The "summary" is a required parameter, but I can still construct the like this:
> n=Notify.Notification()

This can only be fixed with an override right now as we use g_object_new to create objects and don't call constructors directly. There is currently no way to tell if a property has to be set.  In the case of the g_warning it really should be a GError that is returned, not an assert.

I'm not quite sure why the properties aren't being set.  I'll take a look but I am guessing this is a bug in the library, not pygobject.
Comment 3 johnp 2011-03-20 16:51:53 UTC
Ok, yes it is a bug in libnotify which requires the summary be set before any other property is set.  Since we don't order how properties are set, it just so happens that some of the other properties get set before summary is.  In my opinion the library should be fixed to return a GError when the notification is sent over the wire if the summary is not set.  It shouldn't error out until after it first requests the notification daemon to display it.  Reassigning.
Comment 4 johnp 2011-03-20 17:10:13 UTC
Created attachment 183850 [details] [review]
don't assert if summary is not set, return gerror instead

* FIXME: this is just an example of how to fix this issue.
Comment 5 Matthias Clasen 2011-03-21 03:55:12 UTC
Pushed a slightly different fix