device: Better define ownership passing for results
Some things were odd with regard to the ownership of passed objects. Try to make things sane overall, in particular with the possible floating FpPrint reference.
This commit is contained in:
parent
3f3d4559b4
commit
8292c449f7
3 changed files with 29 additions and 17 deletions
|
@ -908,7 +908,7 @@ fpi_device_enroll_complete (FpDevice *device, FpPrint *print, GError *error)
|
||||||
* fpi_device_verify_complete:
|
* fpi_device_verify_complete:
|
||||||
* @device: The #FpDevice
|
* @device: The #FpDevice
|
||||||
* @result: The #FpiMatchResult of the operation
|
* @result: The #FpiMatchResult of the operation
|
||||||
* @print: The scanned #FpPrint
|
* @print: (transfer floating) The scanned #FpPrint
|
||||||
* @error: A #GError if result is %FPI_MATCH_ERROR
|
* @error: A #GError if result is %FPI_MATCH_ERROR
|
||||||
*
|
*
|
||||||
* Finish an ongoing verify operation. The returned print should be
|
* Finish an ongoing verify operation. The returned print should be
|
||||||
|
@ -929,6 +929,9 @@ fpi_device_verify_complete (FpDevice *device,
|
||||||
|
|
||||||
clear_device_cancel_action (device);
|
clear_device_cancel_action (device);
|
||||||
|
|
||||||
|
if (print)
|
||||||
|
g_object_ref_sink (print);
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (priv->current_task),
|
g_object_set_data_full (G_OBJECT (priv->current_task),
|
||||||
"print",
|
"print",
|
||||||
print,
|
print,
|
||||||
|
@ -963,8 +966,8 @@ fpi_device_verify_complete (FpDevice *device,
|
||||||
/**
|
/**
|
||||||
* fpi_device_identify_complete:
|
* fpi_device_identify_complete:
|
||||||
* @device: The #FpDevice
|
* @device: The #FpDevice
|
||||||
* @match: The matching #FpPrint from the passed gallery, or %NULL if none matched
|
* @match: (transfer none): The matching #FpPrint from the passed gallery, or %NULL if none matched
|
||||||
* @print: The scanned #FpPrint, may be %NULL
|
* @print: (transfer floating): The scanned #FpPrint, may be %NULL
|
||||||
* @error: The #GError or %NULL on success
|
* @error: The #GError or %NULL on success
|
||||||
*
|
*
|
||||||
* Finish an ongoing identify operation. The match that was identified is
|
* Finish an ongoing identify operation. The match that was identified is
|
||||||
|
@ -986,6 +989,12 @@ fpi_device_identify_complete (FpDevice *device,
|
||||||
|
|
||||||
clear_device_cancel_action (device);
|
clear_device_cancel_action (device);
|
||||||
|
|
||||||
|
if (match)
|
||||||
|
g_object_ref (match);
|
||||||
|
|
||||||
|
if (print)
|
||||||
|
g_object_ref_sink (print);
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (priv->current_task),
|
g_object_set_data_full (G_OBJECT (priv->current_task),
|
||||||
"print",
|
"print",
|
||||||
print,
|
print,
|
||||||
|
@ -1134,7 +1143,7 @@ fpi_device_list_complete (FpDevice *device,
|
||||||
* fpi_device_enroll_progress:
|
* fpi_device_enroll_progress:
|
||||||
* @device: The #FpDevice
|
* @device: The #FpDevice
|
||||||
* @completed_stages: The number of stages that are completed at this point
|
* @completed_stages: The number of stages that are completed at this point
|
||||||
* @print: (transfer full): The #FpPrint for the newly completed stage or %NULL on failure
|
* @print: (transfer floating): The #FpPrint for the newly completed stage or %NULL on failure
|
||||||
* @error: (transfer full): The #GError or %NULL on success
|
* @error: (transfer full): The #GError or %NULL on success
|
||||||
*
|
*
|
||||||
* Notify about the progress of the enroll operation. This is important for UI interaction.
|
* Notify about the progress of the enroll operation. This is important for UI interaction.
|
||||||
|
@ -1155,6 +1164,9 @@ fpi_device_enroll_progress (FpDevice *device,
|
||||||
|
|
||||||
g_debug ("Device reported enroll progress, reported %i of %i have been completed", completed_stages, priv->nr_enroll_stages);
|
g_debug ("Device reported enroll progress, reported %i of %i have been completed", completed_stages, priv->nr_enroll_stages);
|
||||||
|
|
||||||
|
if (print)
|
||||||
|
g_object_ref_sink (print);
|
||||||
|
|
||||||
if (error && print)
|
if (error && print)
|
||||||
{
|
{
|
||||||
g_warning ("Driver passed an error and also provided a print, returning error!");
|
g_warning ("Driver passed an error and also provided a print, returning error!");
|
||||||
|
|
|
@ -226,7 +226,7 @@ fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, g
|
||||||
|
|
||||||
if (fpi_print_bz3_match (template, print, priv->bz3_threshold, &error) == FPI_MATCH_SUCCESS)
|
if (fpi_print_bz3_match (template, print, priv->bz3_threshold, &error) == FPI_MATCH_SUCCESS)
|
||||||
{
|
{
|
||||||
result = g_object_ref (template);
|
result = template;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,10 +548,10 @@ test_driver_verify (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = fp_print_new (device);
|
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
||||||
|
g_autoptr(FpPrint) out_print = NULL;
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *out_print = NULL;
|
|
||||||
gboolean match;
|
gboolean match;
|
||||||
|
|
||||||
fake_dev->ret_result = FPI_MATCH_SUCCESS;
|
fake_dev->ret_result = FPI_MATCH_SUCCESS;
|
||||||
|
@ -570,10 +570,10 @@ test_driver_verify_fail (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = fp_print_new (device);
|
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
||||||
|
g_autoptr(FpPrint) out_print = NULL;
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *out_print = NULL;
|
|
||||||
gboolean match;
|
gboolean match;
|
||||||
|
|
||||||
fake_dev->ret_result = FPI_MATCH_FAIL;
|
fake_dev->ret_result = FPI_MATCH_FAIL;
|
||||||
|
@ -591,10 +591,10 @@ test_driver_verify_error (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(FpPrint) enrolled_print = fp_print_new (device);
|
g_autoptr(FpPrint) enrolled_print = g_object_ref_sink (fp_print_new (device));
|
||||||
|
g_autoptr(FpPrint) out_print = NULL;
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *out_print = NULL;
|
|
||||||
gboolean match;
|
gboolean match;
|
||||||
|
|
||||||
fake_dev->ret_result = FPI_MATCH_ERROR;
|
fake_dev->ret_result = FPI_MATCH_ERROR;
|
||||||
|
@ -641,16 +641,16 @@ test_driver_identify (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
|
g_autoptr(FpPrint) matched_print = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *matched_print;
|
|
||||||
FpPrint *expected_matched;
|
FpPrint *expected_matched;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
for (i = 0; i < 500; ++i)
|
||||||
g_ptr_array_add (prints, fp_print_new (device));
|
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
||||||
|
|
||||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||||
fp_print_set_description (expected_matched, "fake-verified");
|
fp_print_set_description (expected_matched, "fake-verified");
|
||||||
|
@ -673,15 +673,15 @@ test_driver_identify_fail (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
|
g_autoptr(FpPrint) matched_print = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *matched_print;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
for (i = 0; i < 500; ++i)
|
||||||
g_ptr_array_add (prints, fp_print_new (device));
|
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
||||||
|
|
||||||
g_assert_true (fp_device_supports_identify (device));
|
g_assert_true (fp_device_supports_identify (device));
|
||||||
|
|
||||||
|
@ -700,16 +700,16 @@ test_driver_identify_error (void)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(FpPrint) print = NULL;
|
g_autoptr(FpPrint) print = NULL;
|
||||||
|
g_autoptr(FpPrint) matched_print = NULL;
|
||||||
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
g_autoptr(FpAutoCloseDevice) device = auto_close_fake_device_new ();
|
||||||
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
g_autoptr(GPtrArray) prints = g_ptr_array_new_with_free_func (g_object_unref);
|
||||||
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
FpDeviceClass *dev_class = FP_DEVICE_GET_CLASS (device);
|
||||||
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
FpiDeviceFake *fake_dev = FPI_DEVICE_FAKE (device);
|
||||||
FpPrint *matched_print;
|
|
||||||
FpPrint *expected_matched;
|
FpPrint *expected_matched;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < 500; ++i)
|
for (i = 0; i < 500; ++i)
|
||||||
g_ptr_array_add (prints, fp_print_new (device));
|
g_ptr_array_add (prints, g_object_ref_sink (fp_print_new (device)));
|
||||||
|
|
||||||
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
expected_matched = g_ptr_array_index (prints, g_random_int_range (0, 499));
|
||||||
fp_print_set_description (expected_matched, "fake-verified");
|
fp_print_set_description (expected_matched, "fake-verified");
|
||||||
|
|
Loading…
Reference in a new issue