fix for python called operators getting/setting the operator last used state, also set object.vertex_group_assign.new to false when accessed from blenders UI

This commit is contained in:
Campbell Barton 2012-03-22 02:00:14 +00:00
parent b6c2f9ddab
commit 23c8298ca0
2 changed files with 17 additions and 3 deletions

@ -162,7 +162,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
row = layout.row()
sub = row.row(align=True)
sub.operator("object.vertex_group_assign", text="Assign")
sub.operator("object.vertex_group_assign", text="Assign").new = False
sub.operator("object.vertex_group_remove_from", text="Remove")
sub = row.row(align=True)

@ -751,7 +751,10 @@ int WM_operator_last_properties_init(wmOperator *op)
if (op->type->last_properties) {
PropertyRNA *iterprop;
iterprop= RNA_struct_iterator_property(op->type->srna);
if (G.f & G_DEBUG) printf("%s: loading previous properties for '%s'\n", __func__, op->type->idname);
iterprop = RNA_struct_iterator_property(op->type->srna);
RNA_PROP_BEGIN(op->ptr, itemptr, iterprop) {
PropertyRNA *prop= itemptr.data;
@ -787,6 +790,7 @@ int WM_operator_last_properties_store(wmOperator *op)
}
if (op->properties) {
if (G.f & G_DEBUG) printf("%s: storing properties for '%s'\n", __func__, op->type->idname);
op->type->last_properties = IDP_CopyProperty(op->properties);
return TRUE;
}
@ -1073,8 +1077,18 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA
printf("error \"%s\" operator has no exec function, python cannot call it\n", op->type->name);
#endif
retval= wm_operator_call_internal(C, ot, properties, reports, context, FALSE);
/* not especially nice using undo depth here, its used so py never
* triggers undo or stores operators last used state.
*
* we could have some more obvious way of doing this like passing a flag.
*/
wmWindowManager *wm = CTX_wm_manager(C);
if (wm) wm->op_undo_depth++;
retval = wm_operator_call_internal(C, ot, properties, reports, context, FALSE);
if (wm == CTX_wm_manager(C)) wm->op_undo_depth--;
/* keep the reports around if needed later */
if ( (retval & OPERATOR_RUNNING_MODAL) ||
((retval & OPERATOR_FINISHED) && wm_operator_register_check(CTX_wm_manager(C), ot))