device: Gracefully handle identify on devices with no support
We were crashing as trying to still call the identify vfunc, so check if identification is supported and if not return a relative error. Added test as well
This commit is contained in:
parent
59767af552
commit
4031bb62d7
2 changed files with 17 additions and 0 deletions
|
@ -1038,6 +1038,14 @@ fp_device_identify (FpDevice *device,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fp_device_supports_identify (device))
|
||||||
|
{
|
||||||
|
g_task_return_error (task,
|
||||||
|
fpi_device_error_new_msg (FP_DEVICE_ERROR_NOT_SUPPORTED,
|
||||||
|
"Device has not identification support"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
priv->current_action = FPI_DEVICE_ACTION_IDENTIFY;
|
priv->current_action = FPI_DEVICE_ACTION_IDENTIFY;
|
||||||
priv->current_task = g_steal_pointer (&task);
|
priv->current_task = g_steal_pointer (&task);
|
||||||
maybe_cancel_on_cancelled (device, cancellable);
|
maybe_cancel_on_cancelled (device, cancellable);
|
||||||
|
|
|
@ -849,6 +849,15 @@ class VirtualDevice(VirtualDeviceBase):
|
||||||
|
|
||||||
self.assertEqual(close_res.code, int(FPrint.DeviceError.BUSY))
|
self.assertEqual(close_res.code, int(FPrint.DeviceError.BUSY))
|
||||||
|
|
||||||
|
def test_identify_unsupported(self):
|
||||||
|
if self.dev.supports_identify():
|
||||||
|
self.skipTest('Device supports identification')
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.Error) as error:
|
||||||
|
self.dev.identify_sync([FPrint.Print.new(self.dev)])
|
||||||
|
self.assertTrue(error.exception.matches(FPrint.DeviceError.quark(),
|
||||||
|
FPrint.DeviceError.NOT_SUPPORTED))
|
||||||
|
|
||||||
|
|
||||||
class VirtualDeviceClosed(VirtualDeviceBase):
|
class VirtualDeviceClosed(VirtualDeviceBase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue