fix [#30937] Pose UI hack needed to be undone, alternate fix is needed.

rather then assigning the enum, default to the active pose when the property isnt set.
This commit is contained in:
Campbell Barton 2012-04-23 09:17:37 +00:00
parent b57861e90b
commit 7eaf3eb58e
2 changed files with 18 additions and 8 deletions

@ -204,7 +204,7 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
pose_marker_active = poselib.pose_markers.active
if pose_marker_active is not None:
col.operator("poselib.pose_remove", icon='ZOOMOUT', text="").pose = pose_marker_active.name
col.operator("poselib.pose_remove", icon='ZOOMOUT', text="")
col.operator("poselib.apply_pose", icon='ZOOM_SELECTED', text="").pose_index = poselib.pose_markers.active_index
col.operator("poselib.action_sanitise", icon='HELP', text="") # XXX: put in menu?

@ -516,7 +516,7 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS
int i= 0;
if (C == NULL) {
return DummyRNA_DEFAULT_items;
return DummyRNA_NULL_items;
}
/* check that the action exists */
@ -541,18 +541,28 @@ static int poselib_remove_exec (bContext *C, wmOperator *op)
Object *ob= get_poselib_object(C);
bAction *act= (ob) ? ob->poselib : NULL;
TimeMarker *marker;
int marker_index;
FCurve *fcu;
PropertyRNA *prop;
/* check if valid poselib */
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "Object doesn't have PoseLib data");
return OPERATOR_CANCELLED;
}
prop = RNA_struct_find_property(op->ptr, "pose");
if (RNA_property_is_set(op->ptr, prop)) {
marker_index = RNA_property_enum_get(op->ptr, prop);
}
else {
marker_index = act->active_marker - 1;
}
/* get index (and pointer) of pose to remove */
marker= BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose"));
marker = BLI_findlink(&act->markers, marker_index);
if (marker == NULL) {
BKE_reportf(op->reports, RPT_ERROR, "Invalid Pose specified %d", RNA_int_get(op->ptr, "pose"));
BKE_reportf(op->reports, RPT_ERROR, "Invalid Pose specified %d", marker_index);
return OPERATOR_CANCELLED;
}
@ -605,8 +615,8 @@ void POSELIB_OT_pose_remove (wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "pose", DummyRNA_DEFAULT_items, 0, "Pose", "The pose to remove");
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove");
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
ot->prop = prop;
}