WM: initialize last used macro properties

This commit is contained in:
Campbell Barton 2018-05-11 20:01:51 +02:00
parent d5c1c0b10d
commit 73a7885ab3

@ -1022,11 +1022,10 @@ static void wm_region_mouse_co(bContext *C, wmEvent *event)
}
#if 1 /* may want to disable operator remembering previous state for testing */
bool WM_operator_last_properties_init(wmOperator *op)
static bool operator_last_properties_init_impl(wmOperator *op, IDProperty *last_properties)
{
bool changed = false;
if (op->type->last_properties) {
IDPropertyTemplate val = {0};
IDProperty *replaceprops = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
PropertyRNA *iterprop;
@ -1041,7 +1040,7 @@ bool WM_operator_last_properties_init(wmOperator *op)
if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
if (!RNA_property_is_set(op->ptr, prop)) { /* don't override a setting already set */
const char *identifier = RNA_property_identifier(prop);
IDProperty *idp_src = IDP_GetPropertyFromGroup(op->type->last_properties, identifier);
IDProperty *idp_src = IDP_GetPropertyFromGroup(last_properties, identifier);
if (idp_src) {
IDProperty *idp_dst = IDP_CopyProperty(idp_src);
@ -1062,8 +1061,21 @@ bool WM_operator_last_properties_init(wmOperator *op)
IDP_MergeGroup(op->properties, replaceprops, true);
IDP_FreeProperty(replaceprops);
MEM_freeN(replaceprops);
}
return changed;
}
bool WM_operator_last_properties_init(wmOperator *op)
{
bool changed = false;
if (op->type->last_properties) {
changed |= operator_last_properties_init_impl(op, op->type->last_properties);
for (wmOperator *opm = op->macro.first; opm; opm = opm->next) {
IDProperty *idp_src = IDP_GetPropertyFromGroup(op->type->last_properties, opm->idname);
if (idp_src) {
changed |= operator_last_properties_init_impl(opm, idp_src);
}
}
}
return changed;
}