From 3d02d2f1be192831b48c5abf686e10feaebba8e7 Mon Sep 17 00:00:00 2001 From: Thierry HUCHARD Date: Sun, 12 Apr 2020 10:17:33 +0200 Subject: [PATCH] Changes the status when the trays are empty. --- backend/escl/escl.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/backend/escl/escl.c b/backend/escl/escl.c index 0d3c7fb97..7cc763dea 100644 --- a/backend/escl/escl.c +++ b/backend/escl/escl.c @@ -741,6 +741,8 @@ sane_cancel(SANE_Handle h) handler->scanner->work = SANE_FALSE; handler->cancel = SANE_TRUE; escl_scanner(handler->device, handler->result); + free(handler->result); + handler->result = NULL; } /** @@ -982,8 +984,9 @@ sane_start(SANE_Handle h) handler->ps.pixels_per_line = w; handler->ps.lines = he; handler->ps.bytes_per_line = w * bps; - handler->scanner->work = SANE_FALSE; + handler->ps.last_frame = SANE_TRUE; handler->ps.format = SANE_FRAME_RGB; + handler->scanner->work = SANE_FALSE; // DBG(10, "NEXT Frame [%s]\n", (handler->ps.last_frame ? "Non" : "Oui")); DBG(10, "Real Size Image [%dx%d|%dx%d]\n", 0, 0, w, he); return (status); @@ -1065,14 +1068,11 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len) } } else { + SANE_Status status = SANE_STATUS_EOF; *len = 0; free(handler->scanner->img_data); handler->scanner->img_data = NULL; - if (handler->scanner->source == PLATEN) { - handler->scanner->work = SANE_FALSE; - handler->ps.last_frame = SANE_TRUE; - } - else { + if (handler->scanner->source != PLATEN) { SANE_Status st = escl_status(handler->device, handler->scanner->source, handler->result); @@ -1083,8 +1083,14 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len) SANE_FALSE); handler->scanner->work = next_page; handler->ps.last_frame = !next_page; + if (handler->ps.last_frame = SANE_TRUE) + status = SANE_STATUS_EOF; + else + status = SANE_STATUS_NO_DOCS; } - return (SANE_STATUS_EOF); + else + status = SANE_STATUS_EOF; + return status; } return (SANE_STATUS_GOOD); }