Made modal operators print their operator string after executing

(when in debug "-d" mode only)

copy & paste duplicate and transform operations can now be copied from user input and pasted into ./test.py and run with the Pkey (fixed some minor bugs preventing this)

Would be nice if the "mode" setting used a proper RNA Enum rather then an int. 

# example, duplicate and transform
bpyoperator.OBJECT_OT_add_duplicate(mode=1)
bpyoperator.TFM_OT_transform(mode=1, options=0, values=(-1.23989, 0.570745, 0, 0), constraint_orientation=0, constraint_mode=0, constraint_matrix=(0, 0, 0, 0, 0, 0, 0, 0, 0))
This commit is contained in:
Campbell Barton
2009-01-18 07:35:44 +00:00
parent abfc78afaf
commit 711d04a499
2 changed files with 17 additions and 10 deletions

View File

@@ -1939,7 +1939,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
else {
BLI_dynstr_append(dynstr, "(");
for(i=0; i<len; i++) {
BLI_dynstr_appendf(dynstr, i?"%s, ":"%s", RNA_property_boolean_get_array(ptr, prop, i) ? "True" : "False");
BLI_dynstr_appendf(dynstr, i?", %s":"%s", RNA_property_boolean_get_array(ptr, prop, i) ? "True" : "False");
}
BLI_dynstr_append(dynstr, ")");
}
@@ -1951,19 +1951,19 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
else {
BLI_dynstr_append(dynstr, "(");
for(i=0; i<len; i++) {
BLI_dynstr_appendf(dynstr, i?"%d, ":"%d", RNA_property_int_get_array(ptr, prop, i));
BLI_dynstr_appendf(dynstr, i?", %d":"%d", RNA_property_int_get_array(ptr, prop, i));
}
BLI_dynstr_append(dynstr, ")");
}
break;
case PROP_FLOAT:
if (len==0) {
BLI_dynstr_appendf(dynstr, "%f", RNA_property_float_get(ptr, prop));
BLI_dynstr_appendf(dynstr, "%g", RNA_property_float_get(ptr, prop));
}
else {
BLI_dynstr_append(dynstr, "(");
for(i=0; i<len; i++) {
BLI_dynstr_appendf(dynstr, i?"%f, ":"%f", RNA_property_float_get_array(ptr, prop, i));
BLI_dynstr_appendf(dynstr, i?", %g":"%g", RNA_property_float_get_array(ptr, prop, i));
}
BLI_dynstr_append(dynstr, ")");
}

View File

@@ -448,7 +448,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
if(ot->poll==NULL || ot->poll(C)) {
wmOperator *op= MEM_callocN(sizeof(wmOperator), ot->idname); /* XXX operatortype names are static still. for debug */
if((G.f & G_DEBUG) && event->type!=MOUSEMOVE)
if((G.f & G_DEBUG) && event && event->type!=MOUSEMOVE)
printf("handle evt %d win %d op %s\n", event?event->type:0, CTX_wm_screen(C)->subwinactive, ot->idname);
/* XXX adding new operator could be function, only happens here now */
@@ -482,12 +482,14 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
else
printf("invalid operator call %s\n", ot->idname); /* debug, important to leave a while, should never happen */
if(G.f & G_DEBUG)
WM_operator_print(op);
if(!(retval & OPERATOR_RUNNING_MODAL))
if(!(retval & OPERATOR_RUNNING_MODAL)) {
if(reports==NULL && op->reports->list.first) /* only show the report if the report list was not given in the function */
uiPupmenuReports(C, op->reports);
if (retval & OPERATOR_FINISHED) /* todo - this may conflict with the other WM_operator_print, if theres ever 2 prints for 1 action will may need to add modal check here */
if(G.f & G_DEBUG)
WM_operator_print(op);
}
if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
wm_operator_register(wm, op);
@@ -738,7 +740,12 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
if(!(retval & OPERATOR_RUNNING_MODAL))
if(op->reports->list.first)
uiPupmenuReports(C, op->reports);
if (retval & OPERATOR_FINISHED) {
if(G.f & G_DEBUG)
WM_operator_print(op); /* todo - this print may double up, might want to check more flags then the FINISHED */
}
if((retval & OPERATOR_FINISHED) && (ot->flag & OPTYPE_REGISTER)) {
wm_operator_register(CTX_wm_manager(C), op);
handler->op= NULL;