diff --git a/src/uca-camera.c b/src/uca-camera.c index 341c503..3be70ef 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -363,23 +363,6 @@ uca_camera_dispose (GObject *object) G_OBJECT_CLASS (uca_camera_parent_class)->dispose (object); } -static void -uca_camera_finalize (GObject *object) -{ - GParamSpec **props; - guint n_props; - - /* We will reset property units of all subclassed objects */ - props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &n_props); - - for (guint i = 0; i < n_props; i++) { - g_param_spec_set_qdata (props[i], UCA_UNIT_QUARK, NULL); - } - - g_free (props); - - G_OBJECT_CLASS (uca_camera_parent_class)->finalize (object); -} /* * Make sure the camera reads the actual device state once the child plugin has @@ -405,7 +388,6 @@ uca_camera_class_init (UcaCameraClass *klass) gobject_class->set_property = uca_camera_set_property; gobject_class->get_property = uca_camera_get_property; gobject_class->dispose = uca_camera_dispose; - gobject_class->finalize = uca_camera_finalize; gobject_class->constructed = uca_camera_constructed; klass->start_recording = NULL; diff --git a/test/test-mock.c b/test/test-mock.c index 2efc543..4240e94 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -316,6 +316,53 @@ test_factory_hashtable (Fixture *fixture, gconstpointer data) g_object_unref(camera); } +static void +test_property_units_survive_camera_finalize(Fixture *fixture, + gconstpointer data) +{ + UcaCamera *other_camera; + GError *error = NULL; + + /* Verify the shared property metadata before destroying another instance. */ + g_assert_cmpint( + uca_camera_get_unit(fixture->camera, "roi-height"), + ==, + UCA_UNIT_PIXEL + ); + g_assert_cmpint( + uca_camera_get_unit(fixture->camera, "sensor-bitdepth"), + ==, + UCA_UNIT_COUNT + ); + + other_camera = uca_plugin_manager_get_camera( + fixture->manager, + "mock", + &error, + NULL + ); + g_assert_no_error(error); + g_assert_nonnull(other_camera); + + /* + * This immediately calls uca_camera_finalize() for other_camera. + * Finalizing one instance must not modify class-level GParamSpec metadata + * used by the remaining instance. + */ + g_object_unref(other_camera); + + g_assert_cmpint( + uca_camera_get_unit(fixture->camera, "roi-height"), + ==, + UCA_UNIT_PIXEL + ); + g_assert_cmpint( + uca_camera_get_unit(fixture->camera, "sensor-bitdepth"), + ==, + UCA_UNIT_COUNT + ); +} + int main (int argc, char *argv[]) { gsize n_tests; @@ -345,6 +392,7 @@ int main (int argc, char *argv[]) {"/properties/units", test_property_units}, {"/properties/units/overwrite", test_overwriting_units}, {"/properties/can-be-written", test_can_be_written}, + {"/properties/units/survive-finalize", test_property_units_survive_camera_finalize}, }; n_tests = sizeof(tests) / sizeof(tests[0]);