Skip Menu |

This queue is for tickets about the Sane CPAN distribution.

Maintainer(s)' notes

This queue is shared by both Sane and sane at the moment. Please make it clear in your bug report which distribution you're addressing.

Report information
The Basics
Id: 79152
Status: open
Priority: 0/
Queue: Sane

People
Owner: Nobody in particular
Requestors: perl [...] pied.nu
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.05
Fixed in: (no value)



Subject: sane_exit() is not exported
The included patch exports sane_exit() as Sane->reset(). Calling sane_exit() is important when scanners are hot-plugged, because Sane->list_devices caches the results of the previous call.
Subject: Sane-reset-PG-01.patch
diff -rub Sane-0.05-ORIG/Sane.xs Sane-0.05/Sane.xs --- Sane-0.05-ORIG/Sane.xs 2012-04-02 02:48:28.000000000 -0400 +++ Sane-0.05/Sane.xs 2012-08-22 18:40:09.751933138 -0400 @@ -577,6 +577,17 @@ SANE_Status status void +sane__exit (class) + CODE: + SV* sv = get_sv("Sane::_vc", FALSE); + if (SvTRUE(sv)) { + sv = get_sv("Sane::DEBUG", FALSE); + if (SvTRUE(sv)) printf("Exiting via sane_exit\n"); + sane_exit(); + } + + +void END () CODE: SV* sv = get_sv("Sane::_vc", FALSE); diff -rub Sane-0.05-ORIG/lib/Sane.pm Sane-0.05/lib/Sane.pm --- Sane-0.05-ORIG/lib/Sane.pm 2012-04-02 02:48:27.000000000 -0400 +++ Sane-0.05/lib/Sane.pm 2012-08-22 20:32:14.281091327 -0400 @@ -255,7 +255,7 @@ SANE_NAME_LAMP_OFF_AT_EXIT ); -our $VERSION = '0.05'; +our $VERSION = '0.05-PG1'; our $DEBUG = 0; our ($STATUS, $_status, $_vc); @@ -296,6 +296,12 @@ return Sane::_get_devices(); } +sub reset { + return unless $_vc; + print "Running reset\n" if $DEBUG; + Sane->_exit; + $_vc = undef(); +} # todo # add simple sane methods @@ -458,6 +464,11 @@ print "Type: $devices[0]->{type}\n"; } +=head2 Sane->reset + +This method will release all resources held by the sane library. This +allows the library to rescan the system for new or removed devices. + =head2 Sane::Device->open This function is used to establish a connection to a particular device.
On Wed Aug 22 20:38:47 2012, GWYN wrote: Show quoted text
> The included patch exports sane_exit() as Sane->reset(). > > Calling sane_exit() is important when scanners are hot-plugged, because > Sane->list_devices caches the results of the previous call.
sane_exit IS exported via the END() function, which is called automatically by DESTROY(). i.e. if you undef the Sane object, you should already get the same behaviour
Because I'm only calling Sane->list_devices, I have no Sane object to destroy.
Subject: Re: [rt.cpan.org #79152] sane_exit() is not exported
Date: Sat, 6 Oct 2012 22:29:05 +0200
To: bug-Sane [...] rt.cpan.org
From: Jeffrey Ratcliffe <jeffrey.ratcliffe [...] gmail.com>
On 4 October 2012 02:35, Philip Gwyn via RT <bug-Sane@rt.cpan.org> wrote: Show quoted text
> Because I'm only calling Sane->list_devices, I have no Sane object to > destroy.
Ah. In that case, I think this would be better, as the perl API doesn't change. What do you think? Regards Jeff

Message body is not shown because sender requested not to inline it.

Le Sam 06 Oct 2012 16:29:15, RATCLIFFE a écrit : Show quoted text
> Ah. In that case, I think this would be better, as the perl API > doesn't change. What do you think?
This would work. However, it does things backwards, calling exit() before init(). It should be : print "Running init\n" if $DEBUG; $_vc = Sane->_init; $STATUS = Sane::Status->new; return undef if ($_status); print "Running get_devices\n" if $DEBUG; my @ret = Sane::_get_devices(); print "Running exit\n" if $DEBUG; Sane::_exit; return @ret;