Skip Menu |

This queue is for tickets about the Desktop-Notify CPAN distribution.

Report information
The Basics
Id: 52067
Status: resolved
Priority: 0/
Queue: Desktop-Notify

People
Owner: SACAVILIA [...] cpan.org
Requestors: BlueT [...] cpan.org
james [...] agentultra.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.01
Fixed in: 0.03



Subject: closing a not-shown notification will get Error.
When $notification->close() a created but not $notification->show() yet object, will get the following error. Use of uninitialized value in numeric gt (>) at /usr/share/perl5/Desktop/Notify/Notification.pm line 101. changing 101: if ($self->{id} > 0) to 101: if (defined $self->{id} and $self->{id} > 0) would help. Best wishes, BlueT.
Subject: bug in dbus call?
Date: Wed, 25 Nov 2009 10:35:23 -0500
To: bug-Desktop-Notify [...] rt.cpan.org
From: James King <james [...] agentultra.com>
perl: 5.10.0 os: Ubuntu 9.10 Karmic I copied the example script and turned on warnings and strict but when I run it I get: Argument "" isn't numeric in subroutine entry at /usr/local/lib/perl/5.10.0/Net/DBus/Binding/Iterator.pm line 445. It's just a warning I guess. The script runs fine and the notification does display.
I had the same problem. I did some digging through the code of Desktop::Notify, the code of Net::DBus and the D-Bus protocol spec. I believe the solution is to set the 'id' to 0 (zero) rather than undef. I suggest that this be fixed in Desktop::Notify::Notification::new (version 0.01 line 61) by setting '$self->{id} = 0;' rather than '$self->{id} = undef;' Let me demonstrate. With command line examples: Using Desktop::Notify - perl -MDesktop::Notify -e '$ns=Desktop::Notify->new();$no=$ns->create(summary=>"summary",body=>"body",timeout=>0);$no->show();' This will show a notification, but also emit the error message 'Argument "" isn't numeric in subroutine entry at /usr/lib/perl5/Net/DBus/Binding/Iterator.pm line 445.' You can make a similar call using only Net::DBus which does not emit this error: perl -MNet::DBus -e '$sb=Net::DBus->session;$ns=$sb->get_service("org.freedesktop.Notifications");$no=$ns->get_object("/org/freedesktop/Notifications","org.freedesktop.Notifications");$no->Notify("command line",0,"","Subject","Body",[],{},0);' In this case, the second argument to the Notify() method is set to 0. The second argument is the ID, and per a copy of the Desktop Notifications Spec (http://www.galago-project.org/specs/notification/0.9/x408.html#command-notify) the value should be integer (UINT32). The Desktop::Notify::Notifications modules is setting it to undef, and via autoload method calls the Net::DBus::Binding::Iterator is converting it to an empty string rather than an integer. COMMENTS: I am not sure what an undef integer even looks like. I really like perl's loose type-specing, and I don't think that this bug is a black mark on it. The Desktop Notification Spec clearly states that the 'id' in the message is UINT32, and does not say that undefined is allowed. I can make Desktop::Notification work without emitting the error message by setting the id to 0 prior to calling show() like this: perl -MDesktop::Notify -e '$ns=Desktop::Notify->new();$no=$ns->create(summary=>"summary",body=>"body",timeout=>0);$no->{id}=0;$no->show();' I think that the default value for id should be set to zero in Desktop::Notify::Notification. I just have to figure out how to contact the module author (perhaps this bug report will automatically be sent...I am noew to CPAN-RT).
Yeah, now that I look at it initializing id to undef doesn't make much sense. Also, if you leave timeout undefined it triggers a second warning about the timeout not being numeric.
diff --git a/lib/Desktop/Notify/Notification.pm b/lib/Desktop/Notify/Notification.pm index 40ff79a..4c07c86 100644 --- a/lib/Desktop/Notify/Notification.pm +++ b/lib/Desktop/Notify/Notification.pm @@ -58,7 +58,8 @@ sub new { my $self = \%params; $self->{server} = $server; - $self->{id} = undef; + $self->{id} = 0; + $self->{timeout} = 0; bless $self, $class; }