summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-03-05 12:17:46 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-03-05 12:17:46 +0100
commit2380c982802c8e404b7e4ea58ba74d22c8ab243a (patch)
treeb5fbf89c04fb19fe44e444e75a2b15f06ca529ba
parent8f7201721a823e1daaabbddd20833e5e84baecee (diff)
downloadlibuca-2380c982802c8e404b7e4ea58ba74d22c8ab243a.tar.gz
libuca-2380c982802c8e404b7e4ea58ba74d22c8ab243a.tar.bz2
libuca-2380c982802c8e404b7e4ea58ba74d22c8ab243a.tar.xz
libuca-2380c982802c8e404b7e4ea58ba74d22c8ab243a.zip
Fix error handling
Obviously, unit tests pay off.
-rw-r--r--src/uca-camera.c14
-rw-r--r--test/test-mock.c1
2 files changed, 11 insertions, 4 deletions
diff --git a/src/uca-camera.c b/src/uca-camera.c
index f517d87..a7b266a 100644
--- a/src/uca-camera.c
+++ b/src/uca-camera.c
@@ -211,12 +211,15 @@ void uca_camera_start_recording(UcaCamera *camera, GError **error)
return;
}
- (*klass->start_recording)(camera, error);
+ GError *tmp_error = NULL;
+ (*klass->start_recording)(camera, &tmp_error);
- if (error == NULL) {
+ if (tmp_error == NULL) {
camera->priv->recording = TRUE;
g_object_notify_by_pspec(G_OBJECT(camera), camera_properties[PROP_IS_RECORDING]);
}
+ else
+ g_propagate_error(error, tmp_error);
}
void uca_camera_stop_recording(UcaCamera *camera, GError **error)
@@ -234,12 +237,15 @@ void uca_camera_stop_recording(UcaCamera *camera, GError **error)
return;
}
- (*klass->stop_recording)(camera, error);
+ GError *tmp_error = NULL;
+ (*klass->stop_recording)(camera, &tmp_error);
- if (error == NULL) {
+ if (tmp_error == NULL) {
camera->priv->recording = FALSE;
g_object_notify_by_pspec(G_OBJECT(camera), camera_properties[PROP_IS_RECORDING]);
}
+ else
+ g_propagate_error(error, tmp_error);
}
void uca_camera_set_grab_func(UcaCamera *camera, UcaCameraGrabFunc func)
diff --git a/test/test-mock.c b/test/test-mock.c
index ceb4b20..5831951 100644
--- a/test/test-mock.c
+++ b/test/test-mock.c
@@ -33,6 +33,7 @@ static void test_recording(Fixture *fixture, gconstpointer data)
uca_camera_stop_recording(camera, &error);
g_assert(error != NULL);
+ g_error_free(error);
error = NULL;
uca_camera_start_recording(camera, &error);