Add some more argument validation
authorEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 23 Sep 2010 15:17:24 +0000 (16:17 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 23 Sep 2010 15:17:24 +0000 (16:17 +0100)
This is all internal, so we shouldn't need it; unfortunately, it seems
we're passing invalid data internally, so for the time being catching
inconsistencies should at least emit a warning for us to backtrace.

clutter/clutter-private.h
clutter/clutter-stage.c

index 56221c6..9bc987e 100644 (file)
@@ -276,8 +276,9 @@ int      _clutter_stage_get_pending_swaps      (ClutterStage *stage);
 
 gboolean _clutter_stage_has_full_redraw_queued (ClutterStage *stage);
 
-void     _clutter_stage_set_pick_buffer_valid  (ClutterStage *stage, gboolean valid);
-gboolean _clutter_stage_get_pick_buffer_valid  (ClutterStage *stage);
+void     _clutter_stage_set_pick_buffer_valid             (ClutterStage *stage,
+                                                           gboolean      valid);
+gboolean _clutter_stage_get_pick_buffer_valid             (ClutterStage *stage);
 void     _clutter_stage_increment_picks_per_frame_counter (ClutterStage *stage);
 void     _clutter_stage_reset_picks_per_frame_counter     (ClutterStage *stage);
 guint    _clutter_stage_get_picks_per_frame_counter       (ClutterStage *stage);
index 87ddc1d..0a8efd0 100644 (file)
@@ -2949,29 +2949,40 @@ clutter_stage_get_no_clear_hint (ClutterStage *stage)
 gboolean
 _clutter_stage_get_pick_buffer_valid (ClutterStage *stage)
 {
+  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
+
   return stage->priv->have_valid_pick_buffer;
 }
 
 void
-_clutter_stage_set_pick_buffer_valid (ClutterStage *stage, gboolean valid)
+_clutter_stage_set_pick_buffer_valid (ClutterStage *stage,
+                                      gboolean      valid)
 {
-  stage->priv->have_valid_pick_buffer = valid;
+  g_return_if_fail (CLUTTER_IS_STAGE (stage));
+
+  stage->priv->have_valid_pick_buffer = !!valid;
 }
 
 void
 _clutter_stage_increment_picks_per_frame_counter (ClutterStage *stage)
 {
+  g_return_if_fail (CLUTTER_IS_STAGE (stage));
+
   stage->priv->picks_per_frame++;
 }
 
 void
 _clutter_stage_reset_picks_per_frame_counter (ClutterStage *stage)
 {
+  g_return_if_fail (CLUTTER_IS_STAGE (stage));
+
   stage->priv->picks_per_frame = 0;
 }
 
 guint
 _clutter_stage_get_picks_per_frame_counter (ClutterStage *stage)
 {
+  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), 0);
+
   return stage->priv->picks_per_frame;
 }