avision: Cancel scanning before closing device

escl-add-user-and-password
David Ward 2022-03-27 16:51:30 -04:00
rodzic bd6ad2e092
commit 1277612c5b
1 zmienionych plików z 9 dodań i 11 usunięć

Wyświetl plik

@ -112,7 +112,7 @@
* *
* . . - sane_cancel() : cancel operation, kill reader_process * . . - sane_cancel() : cancel operation, kill reader_process
* *
* . - sane_close() : close opened scanner-device, do_cancel, free buffer and handle * . - sane_close() : do_cancel, close opened scanner-device, free buffer and handle
* - sane_exit() : terminate use of backend, free devicename and device-structure * - sane_exit() : terminate use of backend, free devicename and device-structure
*/ */
@ -8719,22 +8719,14 @@ void
sane_close (SANE_Handle handle) sane_close (SANE_Handle handle)
{ {
Avision_Scanner* prev; Avision_Scanner* prev;
Avision_Scanner* s = handle; Avision_Scanner* s;
int i; int i;
DBG (3, "sane_close:\n"); DBG (3, "sane_close:\n");
/* close the device */ for (prev = 0, s = first_handle; s; prev = s, s = s->next) {
if (avision_is_open (&s->av_con) ) {
avision_close (&s->av_con);
}
/* remove handle from list of open handles: */
prev = 0;
for (s = first_handle; s; s = s->next) {
if (s == handle) if (s == handle)
break; break;
prev = s;
} }
/* a handle we know about ? */ /* a handle we know about ? */
@ -8746,6 +8738,12 @@ sane_close (SANE_Handle handle)
if (s->scanning) if (s->scanning)
do_cancel (handle); do_cancel (handle);
/* close the device */
if (avision_is_open(&s->av_con)) {
avision_close(&s->av_con);
}
/* remove handle from list of open handles */
if (prev) if (prev)
prev->next = s->next; prev->next = s->next;
else else