Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/uca-camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
48 changes: 48 additions & 0 deletions test/test-mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down
Loading