image-device: Avoid invalid state transition on cancellation
Fixes: #226
This commit is contained in:
parent
29a13a9b4a
commit
05bc2e1c80
2 changed files with 15 additions and 5 deletions
|
@ -585,8 +585,6 @@ capture_complete (FpiSsm *ssm, FpDevice *_dev, GError *error)
|
||||||
|
|
||||||
G_DEBUG_HERE ();
|
G_DEBUG_HERE ();
|
||||||
|
|
||||||
/* XXX: cancellation was specially handled by doing nothing! */
|
|
||||||
|
|
||||||
/* either max frames captured or timed out waiting for the next frame */
|
/* either max frames captured or timed out waiting for the next frame */
|
||||||
if (!error ||
|
if (!error ||
|
||||||
(g_error_matches (error, G_USB_DEVICE_ERROR, G_USB_DEVICE_ERROR_TIMED_OUT) &&
|
(g_error_matches (error, G_USB_DEVICE_ERROR, G_USB_DEVICE_ERROR_TIMED_OUT) &&
|
||||||
|
|
|
@ -448,7 +448,9 @@ fpi_image_device_retry_scan (FpImageDevice *self, FpDeviceRetry retry)
|
||||||
* @error: The #GError to report
|
* @error: The #GError to report
|
||||||
*
|
*
|
||||||
* Report an error while interacting with the device. This effectively
|
* Report an error while interacting with the device. This effectively
|
||||||
* aborts the current ongoing action.
|
* aborts the current ongoing action. Note that doing so will result in
|
||||||
|
* the deactivation handler to be called and this function must not be
|
||||||
|
* used to report an error during deactivation.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
fpi_image_device_session_error (FpImageDevice *self, GError *error)
|
fpi_image_device_session_error (FpImageDevice *self, GError *error)
|
||||||
|
@ -475,10 +477,20 @@ fpi_image_device_session_error (FpImageDevice *self, GError *error)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) &&
|
||||||
|
fpi_device_action_is_cancelled (FP_DEVICE (self)))
|
||||||
|
{
|
||||||
|
/* Ignore cancellation errors here, as we will explicitly deactivate
|
||||||
|
* anyway (or, may already have done so at this point).
|
||||||
|
*/
|
||||||
|
g_debug ("Driver reported a cancellation error, this is expected but not required. Ignoring.");
|
||||||
|
g_clear_error (&error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
else if (priv->state == FPI_IMAGE_DEVICE_STATE_INACTIVE)
|
else if (priv->state == FPI_IMAGE_DEVICE_STATE_INACTIVE)
|
||||||
{
|
{
|
||||||
g_warning ("Driver reported session error; translating to deactivation failure.");
|
g_warning ("Driver reported session error while deactivating already, ignoring. This indicates a driver bug.");
|
||||||
fpi_image_device_deactivate_complete (self, error);
|
g_clear_error (&error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue