summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-08-13 14:16:17 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-08-13 14:16:17 +0200
commit972bc48715450e61ae79c705b95ddabcc2b1bbc9 (patch)
tree4e26ee2930777744ef5a647f68a2b5aa117ff488
parent04767fda6abe4bc71bbf061122ad723cc8addcc1 (diff)
downloadlibuca-972bc48715450e61ae79c705b95ddabcc2b1bbc9.tar.gz
libuca-972bc48715450e61ae79c705b95ddabcc2b1bbc9.tar.bz2
libuca-972bc48715450e61ae79c705b95ddabcc2b1bbc9.tar.xz
libuca-972bc48715450e61ae79c705b95ddabcc2b1bbc9.zip
Fix re-setting a unit on the same camera class
-rw-r--r--src/uca-camera.c8
-rw-r--r--src/uca-camera.h2
-rw-r--r--test/test-mock.c7
3 files changed, 9 insertions, 8 deletions
diff --git a/src/uca-camera.c b/src/uca-camera.c
index 8bb7201..27af765 100644
--- a/src/uca-camera.c
+++ b/src/uca-camera.c
@@ -135,8 +135,12 @@ struct _UcaCameraPrivate {
static void
uca_camera_set_property_unit (GParamSpec *pspec, UcaUnit unit)
{
- if (g_param_spec_get_qdata (pspec, UCA_UNIT_QUARK) != NULL)
- g_warning ("::%s already has a unit", pspec->name);
+ UcaUnit old_unit;
+
+ old_unit = (UcaUnit) GPOINTER_TO_INT (g_param_spec_get_qdata (pspec, UCA_UNIT_QUARK));
+
+ if (old_unit != unit && old_unit != UCA_UNIT_NA)
+ g_warning ("::%s already has a different unit", pspec->name);
else
g_param_spec_set_qdata (pspec, UCA_UNIT_QUARK, GINT_TO_POINTER (unit));
}
diff --git a/src/uca-camera.h b/src/uca-camera.h
index daa2bda..f4030d6 100644
--- a/src/uca-camera.h
+++ b/src/uca-camera.h
@@ -51,7 +51,7 @@ typedef enum {
} UcaCameraTrigger;
typedef enum {
- UCA_UNIT_NA,
+ UCA_UNIT_NA = 0,
UCA_UNIT_METER,
UCA_UNIT_SECOND,
UCA_UNIT_PIXEL,
diff --git a/test/test-mock.c b/test/test-mock.c
index de1e18d..d1dcf3a 100644
--- a/test/test-mock.c
+++ b/test/test-mock.c
@@ -224,11 +224,7 @@ test_signal (Fixture *fixture, gconstpointer data)
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);
+ uca_camera_register_unit (fixture->camera, "sensor-width", UCA_UNIT_PIXEL);
}
int main (int argc, char *argv[])
@@ -249,6 +245,7 @@ int main (int argc, char *argv[])
g_test_add ("/properties/binnings", Fixture, NULL, fixture_setup, test_binnings_properties, fixture_teardown);
g_test_add ("/properties/frames-per-second", Fixture, NULL, fixture_setup, test_fps_property, fixture_teardown);
g_test_add ("/properties/units", Fixture, NULL, fixture_setup, test_property_units, fixture_teardown);
+ g_test_add ("/properties/units/overwrite", Fixture, NULL, fixture_setup, test_overwriting_units, fixture_teardown);
g_test_add ("/signal", Fixture, NULL, fixture_setup, test_signal, fixture_teardown);
return g_test_run ();