Fix T60643: BMesh operator enum args fail when unset from Python

Error introduced with bmesh operator enum support: 1e6a5eb087
This commit is contained in:
2019-01-22 14:26:15 +11:00
parent 88218946da
commit a93cbb70cd
3 changed files with 8 additions and 4 deletions

View File

@@ -228,7 +228,11 @@ typedef struct BMOpSlot {
float vec[3]; float vec[3];
void **buf; void **buf;
GHash *ghash; GHash *ghash;
BMO_FlagSet *enum_flags; struct {
/** Don't clobber (i) when assigning flags, see #eBMOpSlotSubType_Int. */
int _i;
BMO_FlagSet *flags;
} enum_data;
} data; } data;
} BMOpSlot; } BMOpSlot;

View File

@@ -142,7 +142,7 @@ static void bmo_op_slots_init(const BMOSlotType *slot_types, BMOpSlot *slot_args
break; break;
case BMO_OP_SLOT_INT: case BMO_OP_SLOT_INT:
if (ELEM(slot->slot_subtype.intg, BMO_OP_SLOT_SUBTYPE_INT_ENUM, BMO_OP_SLOT_SUBTYPE_INT_FLAG)) { if (ELEM(slot->slot_subtype.intg, BMO_OP_SLOT_SUBTYPE_INT_ENUM, BMO_OP_SLOT_SUBTYPE_INT_FLAG)) {
slot->data.enum_flags = slot_types[i].enum_flags; slot->data.enum_data.flags = slot_types[i].enum_flags;
} }
default: default:
break; break;

View File

@@ -173,7 +173,7 @@ static int bpy_slot_from_py(
{ {
if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) { if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) {
int enum_val = -1; int enum_val = -1;
PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags; PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_data.flags;
const char *enum_str = _PyUnicode_AsString(value); const char *enum_str = _PyUnicode_AsString(value);
if (enum_str == NULL) { if (enum_str == NULL) {
@@ -191,7 +191,7 @@ static int bpy_slot_from_py(
} }
else if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) { else if (slot->slot_subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) {
int flag = 0; int flag = 0;
PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_flags; PyC_FlagSet *items = (PyC_FlagSet *)slot->data.enum_data.flags;
if (PyC_FlagSet_ToBitfield(items, value, &flag, slot_name) == -1) { if (PyC_FlagSet_ToBitfield(items, value, &flag, slot_name) == -1) {
return -1; return -1;