diff options
Diffstat (limited to 'source/blender/editors/armature/poselib.c')
-rw-r--r-- | source/blender/editors/armature/poselib.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 9577c45de50..13a8cef3d07 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -141,11 +141,18 @@ static TimeMarker *poselib_get_active_pose (bAction *act) } /* Get object that Pose Lib should be found on */ + /* XXX C can be zero */ static Object *get_poselib_object (bContext *C) { - ScrArea *sa = CTX_wm_area(C); + ScrArea *sa; - if (sa->spacetype == SPACE_BUTS) + /* sanity check */ + if (C == NULL) + return NULL; + + sa = CTX_wm_area(C); + + if (sa && (sa->spacetype == SPACE_BUTS)) return CTX_data_pointer_get_type(C, "object", &RNA_Object).data; else return ED_object_pose_armature(CTX_data_active_object(C)); @@ -342,7 +349,7 @@ void POSELIB_OT_action_sanitise (wmOperatorType *ot) static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, void *UNUSED(arg)) { Object *ob= get_poselib_object(C); - bAction *act= ob->poselib; + bAction *act= (ob) ? ob->poselib : NULL; TimeMarker *marker; /* set the operator execution context correctly */ @@ -473,8 +480,8 @@ void POSELIB_OT_pose_add (wmOperatorType *ot) /* can be called with C == NULL */ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUSED(ptr), int *free) { - Object *ob; - bAction *act; + Object *ob = get_poselib_object(C); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; EnumPropertyItem *item= NULL, item_tmp= {0}; int totitem= 0; @@ -484,9 +491,6 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS return DummyRNA_DEFAULT_items; } - ob= get_poselib_object(C); - act= (ob) ? ob->poselib : NULL; - /* check that the action exists */ if (act) { /* add each marker to the list */ |