[glide] API guards for actor



commit 38e7da145677cde34cd54c5475b12a56f715d94d
Author: Robert Carr <racarr Valentine localdomain>
Date:   Fri May 7 13:25:45 2010 -0400

    API guards for actor

 libglide/glide-actor.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/libglide/glide-actor.c b/libglide/glide-actor.c
index a4ae4a5..425ec9b 100644
--- a/libglide/glide-actor.c
+++ b/libglide/glide-actor.c
@@ -220,6 +220,8 @@ glide_actor_init (GlideActor *actor)
 GlideStageManager *
 glide_actor_get_stage_manager (GlideActor *actor)
 {
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
+
   return actor->priv->manager;
 }
 
@@ -234,6 +236,8 @@ glide_actor_get_stage_manager (GlideActor *actor)
 gboolean
 glide_actor_get_selected (GlideActor *actor)
 {
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
+
   return actor->priv->selected;
 }
 
@@ -250,6 +254,9 @@ glide_actor_get_selected (GlideActor *actor)
 void
 glide_actor_set_stage_manager (GlideActor *actor, GlideStageManager *manager)
 {
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
+  g_return_if_fail (GLIDE_IS_STAGE_MANAGER (manager));
+
   glide_actor_set_stage_manager_real (actor, manager);
 }
 
@@ -267,6 +274,8 @@ glide_actor_serialize (GlideActor *actor)
 {
   GlideActorClass *klass;
   
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
+  
   klass = GLIDE_ACTOR_GET_CLASS (actor);
   if (klass->serialize)
     {
@@ -292,6 +301,8 @@ glide_actor_deserialize (GlideActor *actor, JsonObject *actor_obj)
 {
   GlideActorClass *klass;
   
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
+  
   klass = GLIDE_ACTOR_GET_CLASS (actor);
   if (klass->deserialize)
     klass->deserialize (actor, actor_obj);
@@ -309,13 +320,15 @@ glide_actor_deserialize (GlideActor *actor, JsonObject *actor_obj)
  *
  */
 void 
-glide_actor_print (GlideActor *aactor, cairo_t *cr)
+glide_actor_print (GlideActor *actor, cairo_t *cr)
 {
   GlideActorClass *klass;
   
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
+  
   klass = GLIDE_ACTOR_GET_CLASS (actor);
   if (klass->print)
-    klass->print (aactor, cr);
+    klass->print (actor, cr);
 }
 
 
@@ -336,9 +349,13 @@ GlideActor *
 glide_actor_construct_from_json (GlideStageManager *manager, 
 				 JsonObject *actor_obj)
 {
-  const gchar *a_type = glide_json_object_get_string (actor_obj, "type");
+  const gchar *a_type;
   GlideActor *ret;
   
+  g_return_val_if_fail (GLIDE_IS_STAGE_MANAGER (manager), NULL);
+  
+  a_type = glide_json_object_get_string (actor_obj, "type");
+  
   if (!strcmp(a_type, "image"))
     {
       ret = (GlideActor *)glide_image_new ();
@@ -374,6 +391,7 @@ glide_actor_construct_from_json (GlideStageManager *manager,
 GlideUndoManager *
 glide_actor_get_undo_manager (GlideActor *actor)
 {
+  g_return_val_if_fail (GLIDE_IS_ACTOR (actor), NULL);
   return glide_stage_manager_get_undo_manager (actor->priv->manager);
 }
 
@@ -389,6 +407,7 @@ glide_actor_get_undo_manager (GlideActor *actor)
 gchar *
 glide_actor_add_resource (GlideActor *actor, const gchar *filename)
 {
+  g_return_val_if_fail (GLIDE_IS_ACTOR (actor), NULL);
   return glide_document_add_resource (glide_stage_manager_get_document (glide_actor_get_stage_manager (actor)), filename);
 }
 
@@ -405,6 +424,7 @@ glide_actor_add_resource (GlideActor *actor, const gchar *filename)
 gchar *
 glide_actor_get_resource_path (GlideActor *actor, const gchar *resource_name)
 {
+  g_return_val_if_fail (GLIDE_IS_ACTOR (actor), NULL);
   return glide_document_get_resource_path (glide_stage_manager_get_document (glide_actor_get_stage_manager (actor)), resource_name);
 }
 
@@ -419,6 +439,7 @@ glide_actor_get_resource_path (GlideActor *actor, const gchar *resource_name)
 void
 glide_actor_start_undo (GlideActor *actor, const gchar *label)
 {
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
   glide_undo_manager_start_actor_action (glide_actor_get_undo_manager (actor), actor, label);
 }
 
@@ -432,5 +453,6 @@ glide_actor_start_undo (GlideActor *actor, const gchar *label)
 void
 glide_actor_end_undo (GlideActor *actor)
 {
+  g_return_if_fail (GLIDE_IS_ACTOR (actor));
   glide_undo_manager_end_actor_action (glide_actor_get_undo_manager (actor), actor);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]