[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50818] trunk/blender/source/blender: fix for all pose-group editing functions crashing when the context didnt have an area (in background mode),
Campbell Barton
ideasman42 at gmail.com
Sun Sep 23 04:31:33 CEST 2012
Revision: 50818
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50818
Author: campbellbarton
Date: 2012-09-23 02:31:30 +0000 (Sun, 23 Sep 2012)
Log Message:
-----------
fix for all pose-group editing functions crashing when the context didnt have an area (in background mode),
fix pose-group-sort and pose-group-moving being disabled for pinned poses.
also fix for own missing NULL check for pose mask clear which would crash when run without an active object
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_object.h
trunk/blender/source/blender/blenkernel/intern/object.c
trunk/blender/source/blender/editors/armature/poseobject.c
trunk/blender/source/blender/editors/include/ED_armature.h
trunk/blender/source/blender/editors/include/ED_screen.h
trunk/blender/source/blender/editors/mesh/mesh_data.c
trunk/blender/source/blender/editors/screen/screen_ops.c
Modified: trunk/blender/source/blender/blenkernel/BKE_object.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_object.h 2012-09-22 20:07:30 UTC (rev 50817)
+++ trunk/blender/source/blender/blenkernel/BKE_object.h 2012-09-23 02:31:30 UTC (rev 50818)
@@ -93,6 +93,7 @@
void BKE_object_to_mat4(struct Object *ob, float mat[][4]);
void BKE_object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent);
+int BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob);
Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c 2012-09-22 20:07:30 UTC (rev 50817)
+++ trunk/blender/source/blender/blenkernel/intern/object.c 2012-09-23 02:31:30 UTC (rev 50818)
@@ -1079,12 +1079,12 @@
}
}
-static int object_pose_context(Object *ob)
+int BKE_object_pose_context_check(Object *ob)
{
- if ( (ob) &&
- (ob->type == OB_ARMATURE) &&
- (ob->pose) &&
- (ob->mode & OB_MODE_POSE))
+ if ((ob) &&
+ (ob->type == OB_ARMATURE) &&
+ (ob->pose) &&
+ (ob->mode & OB_MODE_POSE))
{
return 1;
}
@@ -1098,12 +1098,12 @@
if (ob == NULL)
return NULL;
- if (object_pose_context(ob))
+ if (BKE_object_pose_context_check(ob))
return ob;
ob = modifiers_isDeformedByArmature(ob);
- if (object_pose_context(ob))
+ if (BKE_object_pose_context_check(ob))
return ob;
return NULL;
Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c 2012-09-22 20:07:30 UTC (rev 50817)
+++ trunk/blender/source/blender/editors/armature/poseobject.c 2012-09-23 02:31:30 UTC (rev 50818)
@@ -81,6 +81,23 @@
#include "armature_intern.h"
+/* matches logic with ED_operator_posemode_context() */
+Object *ED_pose_object_from_context(bContext *C)
+{
+ ScrArea *sa = CTX_wm_area(C);
+ Object *ob;
+
+ /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ if (sa && sa->spacetype == SPACE_BUTS) {
+ ob = ED_object_context(C);
+ }
+ else {
+ ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ }
+
+ return ob;
+}
+
/* This function is used to process the necessary updates for */
void ED_armature_enter_posemode(bContext *C, Base *base)
{
@@ -1331,15 +1348,8 @@
static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+ Object *ob = ED_pose_object_from_context(C);
+
/* only continue if there's an object */
if (ob == NULL)
return OPERATOR_CANCELLED;
@@ -1362,7 +1372,7 @@
/* api callbacks */
ot->exec = pose_group_add_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1371,15 +1381,8 @@
static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object */
if (ob == NULL)
return OPERATOR_CANCELLED;
@@ -1402,7 +1405,7 @@
/* api callbacks */
ot->exec = pose_group_remove_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1413,8 +1416,7 @@
/* invoke callback which presents a list of bone-groups for the user to choose from */
static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose;
uiPopupMenu *pup;
@@ -1422,12 +1424,6 @@
bActionGroup *grp;
int i;
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1466,17 +1462,10 @@
/* Assign selected pchans to the bone group that the user selects */
static int pose_group_assign_exec(bContext *C, wmOperator *op)
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose;
short done = FALSE;
-
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1518,7 +1507,7 @@
/* api callbacks */
ot->invoke = pose_groups_menu_invoke;
ot->exec = pose_group_assign_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1530,16 +1519,9 @@
static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
short done = FALSE;
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1573,7 +1555,7 @@
/* api callbacks */
ot->exec = pose_group_unassign_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1581,7 +1563,7 @@
static int group_move_exec(bContext *C, wmOperator *op)
{
- Object *ob = ED_object_context(C);
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan;
bActionGroup *grp;
@@ -1654,7 +1636,7 @@
/* api callbacks */
ot->exec = group_move_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1679,7 +1661,7 @@
static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob = ED_object_context(C);
+ Object *ob = ED_pose_object_from_context(C);
bPose *pose = (ob) ? ob->pose : NULL;
bPoseChannel *pchan;
tSortActionGroup *agrp_array;
@@ -1738,7 +1720,7 @@
/* api callbacks */
ot->exec = group_sort_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1766,15 +1748,8 @@
static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1796,7 +1771,7 @@
/* api callbacks */
ot->exec = pose_group_select_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1804,15 +1779,8 @@
static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
{
- ScrArea *sa = CTX_wm_area(C);
- Object *ob;
+ Object *ob = ED_pose_object_from_context(C);
- /* since this call may also be used from the buttons window, we need to check for where to get the object */
- if (sa->spacetype == SPACE_BUTS)
- ob = ED_object_context(C);
- else
- ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
@@ -1834,7 +1802,7 @@
/* api callbacks */
ot->exec = pose_group_deselect_exec;
- ot->poll = ED_operator_posemode;
+ ot->poll = ED_operator_posemode_context;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
Modified: trunk/blender/source/blender/editors/include/ED_armature.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_armature.h 2012-09-22 20:07:30 UTC (rev 50817)
+++ trunk/blender/source/blender/editors/include/ED_armature.h 2012-09-23 02:31:30 UTC (rev 50818)
@@ -148,6 +148,7 @@
int ED_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
void ED_pose_deselectall(struct Object *ob, int test);
void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
+struct Object *ED_pose_object_from_context(struct bContext *C);
/* sketch */
Modified: trunk/blender/source/blender/editors/include/ED_screen.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_screen.h 2012-09-22 20:07:30 UTC (rev 50817)
+++ trunk/blender/source/blender/editors/include/ED_screen.h 2012-09-23 02:31:30 UTC (rev 50818)
@@ -171,6 +171,7 @@
int ED_operator_uvedit(struct bContext *C);
int ED_operator_uvmap(struct bContext *C);
int ED_operator_posemode_exclusive(struct bContext *C);
+int ED_operator_posemode_context(struct bContext *C);
int ED_operator_posemode(struct bContext *C);
int ED_operator_mask(struct bContext *C);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list