From b4beea2f9337014d522436cdf645291e0163d51a Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 7 Aug 2014 12:33:47 +0200 Subject: Reset all property units and warn on override --- src/uca-camera.c | 11 +++++++++++ test/test-mock.c | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/uca-camera.c b/src/uca-camera.c index ae8fea9..8bb7201 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -306,11 +306,22 @@ static void uca_camera_finalize (GObject *object) { UcaCameraPrivate *priv; + GParamSpec **props; + guint n_props; priv = UCA_CAMERA_GET_PRIVATE (object); g_value_array_free (priv->h_binnings); g_value_array_free (priv->v_binnings); + /* 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); } diff --git a/test/test-mock.c b/test/test-mock.c index facae53..de1e18d 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -221,6 +221,16 @@ test_signal (Fixture *fixture, gconstpointer data) g_assert (success == TRUE); } +static void +test_overwriting_units (Fixture *fixture, gconstpointer data) +{ + UcaUnit unit; + + uca_camera_register_unit (fixture->camera, "frames-per-second", UCA_UNIT_PIXEL); + unit = uca_camera_get_unit (fixture->camera, "frames-per-second"); + g_assert (unit != UCA_UNIT_PIXEL); +} + int main (int argc, char *argv[]) { #if !(GLIB_CHECK_VERSION (2, 36, 0)) -- cgit v1.2.3