kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Return errors as exceptions from *eject_document()
rodzic
0bc253de07
commit
a6cbb98069
|
@ -3278,7 +3278,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -3345,7 +3345,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -3365,7 +3365,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||
throw;
|
||||
}
|
||||
forward = SANE_FALSE;
|
||||
|
@ -3382,7 +3382,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -3404,7 +3404,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -3439,13 +3439,8 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
/* save the calibration data */
|
||||
genesys_save_calibration (dev, sensor);
|
||||
|
||||
/* and finally eject calibration sheet */
|
||||
status = dev->model->cmd_set->eject_document (dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to eject document: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
// and finally eject calibration sheet
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
|
||||
/* resotre settings */
|
||||
dev->settings.xres = xres;
|
||||
|
@ -6227,7 +6222,7 @@ sane_close_impl(SANE_Handle handle)
|
|||
/* eject document for sheetfed scanners */
|
||||
if (s->dev->model->is_sheetfed == SANE_TRUE)
|
||||
{
|
||||
s->dev->model->cmd_set->eject_document (s->dev);
|
||||
catch_all_exceptions(__func__, [&](){ s->dev->model->cmd_set->eject_document(s->dev); });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7292,12 +7287,7 @@ void sane_cancel_impl(SANE_Handle handle)
|
|||
}
|
||||
else
|
||||
{ /* in case of sheetfed scanners, we have to eject the document if still present */
|
||||
status = s->dev->model->cmd_set->eject_document (s->dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to eject document: %s\n", __func__, sane_strstatus(status));
|
||||
return;
|
||||
}
|
||||
s->dev->model->cmd_set->eject_document(s->dev);
|
||||
}
|
||||
|
||||
/* enable power saving mode unless we are parking .... */
|
||||
|
|
|
@ -1787,11 +1787,9 @@ gl646_detect_document_end (Genesys_Device * dev)
|
|||
* TODO we currently rely on AGOHOME not being set for sheetfed scanners,
|
||||
* maybe check this flag in eject to let the document being eject automaticaly
|
||||
*/
|
||||
static SANE_Status
|
||||
gl646_eject_document (Genesys_Device * dev)
|
||||
static void gl646_eject_document(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
SANE_Status status = SANE_STATUS_GOOD;
|
||||
|
||||
// FIXME: SEQUENTIAL not really needed in this case
|
||||
Genesys_Register_Set regs((Genesys_Register_Set::SEQUENTIAL));
|
||||
|
@ -1822,7 +1820,7 @@ gl646_eject_document (Genesys_Device * dev)
|
|||
dev->document = SANE_FALSE;
|
||||
DBG(DBG_info, "%s: no more document to eject\n", __func__);
|
||||
DBG(DBG_proc, "%s: end\n", __func__);
|
||||
return status;
|
||||
return;
|
||||
}
|
||||
|
||||
// there is a document inserted, eject it
|
||||
|
@ -1892,8 +1890,6 @@ gl646_eject_document (Genesys_Device * dev)
|
|||
gl646_gpio_read(dev->usb_dev, &gpio);
|
||||
|
||||
DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// Send the low-level scan command
|
||||
|
@ -1952,12 +1948,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
|
|||
{
|
||||
if (eject == SANE_TRUE && dev->document == SANE_TRUE)
|
||||
{
|
||||
status = gl646_eject_document (dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to eject document\n", __func__);
|
||||
return status;
|
||||
}
|
||||
gl646_eject_document(dev);
|
||||
}
|
||||
if (check_stop)
|
||||
{
|
||||
|
|
|
@ -2530,8 +2530,7 @@ static void gl841_get_paper_sensor(Genesys_Device* dev, SANE_Bool * paper_loaded
|
|||
*paper_loaded = (val & 0x1) == 0;
|
||||
}
|
||||
|
||||
static SANE_Status
|
||||
gl841_eject_document (Genesys_Device * dev)
|
||||
static void gl841_eject_document(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
Genesys_Register_Set local_reg;
|
||||
|
@ -2545,7 +2544,7 @@ gl841_eject_document (Genesys_Device * dev)
|
|||
{
|
||||
DBG(DBG_proc, "%s: there is no \"eject sheet\"-concept for non sheet fed\n", __func__);
|
||||
DBG(DBG_proc, "%s: finished\n", __func__);
|
||||
return SANE_STATUS_GOOD;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2606,10 +2605,11 @@ gl841_eject_document (Genesys_Device * dev)
|
|||
|
||||
if (loop == 0)
|
||||
{
|
||||
/* when we come here then the scanner needed too much time for this, so we better stop the motor */
|
||||
gl841_stop_action (dev);
|
||||
DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__);
|
||||
return SANE_STATUS_IO_ERROR;
|
||||
// when we come here then the scanner needed too much time for this, so we better stop
|
||||
// the motor
|
||||
catch_all_exceptions(__func__, [&](){ gl841_stop_action(dev); });
|
||||
throw SaneException(SANE_STATUS_IO_ERROR,
|
||||
"timeout while waiting for scanhead to go home");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2643,8 +2643,6 @@ gl841_eject_document (Genesys_Device * dev)
|
|||
gl841_stop_action(dev);
|
||||
|
||||
dev->document = SANE_FALSE;
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1775,13 +1775,10 @@ static void gl843_get_paper_sensor(Genesys_Device* dev, SANE_Bool * paper_loaded
|
|||
*paper_loaded = (val & 0x1) == 0;
|
||||
}
|
||||
|
||||
static SANE_Status
|
||||
gl843_eject_document (Genesys_Device * dev)
|
||||
static void gl843_eject_document(Genesys_Device* dev)
|
||||
{
|
||||
(void) dev;
|
||||
DBG_HELPER(dbg);
|
||||
if (dev == NULL)
|
||||
return SANE_STATUS_INVAL;
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1115,7 +1115,7 @@ struct Genesys_Command_Set
|
|||
/**
|
||||
* eject document from scanner
|
||||
*/
|
||||
SANE_Status (*eject_document) (Genesys_Device * dev);
|
||||
void (*eject_document) (Genesys_Device* dev);
|
||||
/**
|
||||
* search for an black or white area in forward or reverse
|
||||
* direction */
|
||||
|
|
Ładowanie…
Reference in New Issue