Fix #34862: some operators like mesh separate or object clear parent were not
showing shortcuts in menus, now it shows them in the submenu.
This commit is contained in:
@@ -549,7 +549,7 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", "");
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, CLEAR_PARENT_ALL, "Type", "");
|
||||
}
|
||||
|
||||
/* ******************** Make Parent Operator *********************** */
|
||||
|
||||
@@ -1077,10 +1077,11 @@ __attribute__ ((format(printf, 1, 2)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/* Equals test (skips pointers and collections) */
|
||||
/* Equals test (skips pointers and collections)
|
||||
* is_strict false assumes uninitialized properties are equal */
|
||||
|
||||
int RNA_property_equals(struct PointerRNA *a, struct PointerRNA *b, struct PropertyRNA *prop);
|
||||
int RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b);
|
||||
bool RNA_property_equals(struct PointerRNA *a, struct PointerRNA *b, struct PropertyRNA *prop, bool is_strict);
|
||||
bool RNA_struct_equals(struct PointerRNA *a, struct PointerRNA *b, bool is_strict);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -6179,14 +6179,19 @@ void _RNA_warning(const char *format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop)
|
||||
bool RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop, bool is_strict)
|
||||
{
|
||||
/* if not strict, uninitialized properties are assumed to match */
|
||||
if (!is_strict)
|
||||
if (!(RNA_property_is_set(a, prop) && RNA_property_is_set(b, prop)))
|
||||
return true;
|
||||
|
||||
/* get the length of the array to work with */
|
||||
int len = RNA_property_array_length(a, prop);
|
||||
int fromlen = RNA_property_array_length(b, prop);
|
||||
|
||||
if (len != fromlen)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
/* get and set the default values as appropriate for the various types */
|
||||
switch (RNA_property_type(prop)) {
|
||||
@@ -6195,7 +6200,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop)
|
||||
if (len) {
|
||||
int fixed_a[16], fixed_b[16];
|
||||
int *array_a, *array_b;
|
||||
int equals;
|
||||
bool equals;
|
||||
|
||||
array_a = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals") : fixed_a;
|
||||
array_b = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals") : fixed_b;
|
||||
@@ -6221,7 +6226,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop)
|
||||
if (len) {
|
||||
int fixed_a[16], fixed_b[16];
|
||||
int *array_a, *array_b;
|
||||
int equals;
|
||||
bool equals;
|
||||
|
||||
array_a = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_a;
|
||||
array_b = (len > 16) ? MEM_callocN(sizeof(int) * len, "RNA equals"): fixed_b;
|
||||
@@ -6247,7 +6252,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop)
|
||||
if (len) {
|
||||
float fixed_a[16], fixed_b[16];
|
||||
float *array_a, *array_b;
|
||||
int equals;
|
||||
bool equals;
|
||||
|
||||
array_a = (len > 16) ? MEM_callocN(sizeof(float) * len, "RNA equals") : fixed_a;
|
||||
array_b = (len > 16) ? MEM_callocN(sizeof(float) * len, "RNA equals") : fixed_b;
|
||||
@@ -6280,7 +6285,7 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop)
|
||||
int len_a, len_b;
|
||||
char *value_a = RNA_property_string_get_alloc(a, prop, fixed_a, sizeof(fixed_a), &len_a);
|
||||
char *value_b = RNA_property_string_get_alloc(b, prop, fixed_b, sizeof(fixed_b), &len_b);
|
||||
int equals = strcmp(value_a, value_b) == 0;
|
||||
bool equals = strcmp(value_a, value_b) == 0;
|
||||
|
||||
if (value_a != fixed_a) MEM_freeN(value_a);
|
||||
if (value_b != fixed_b) MEM_freeN(value_b);
|
||||
@@ -6292,22 +6297,22 @@ int RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop)
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
int RNA_struct_equals(PointerRNA *a, PointerRNA *b)
|
||||
bool RNA_struct_equals(PointerRNA *a, PointerRNA *b, bool is_strict)
|
||||
{
|
||||
CollectionPropertyIterator iter;
|
||||
// CollectionPropertyRNA *citerprop; /* UNUSED */
|
||||
PropertyRNA *iterprop;
|
||||
int equals = 1;
|
||||
bool equals = true;
|
||||
|
||||
if (a == NULL && b == NULL)
|
||||
return 1;
|
||||
return true;
|
||||
else if (a == NULL || b == NULL)
|
||||
return 0;
|
||||
return false;
|
||||
else if (a->type != b->type)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
iterprop = RNA_struct_iterator_property(a->type);
|
||||
// citerprop = (CollectionPropertyRNA *)rna_ensure_property(iterprop); /* UNUSED */
|
||||
@@ -6316,8 +6321,8 @@ int RNA_struct_equals(PointerRNA *a, PointerRNA *b)
|
||||
for (; iter.valid; RNA_property_collection_next(&iter)) {
|
||||
PropertyRNA *prop = iter.ptr.data;
|
||||
|
||||
if (!RNA_property_equals(a, b, prop)) {
|
||||
equals = 0;
|
||||
if (!RNA_property_equals(a, b, prop, is_strict)) {
|
||||
equals = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b)
|
||||
if (strcmp(a->idname, b->idname) != 0)
|
||||
return 0;
|
||||
|
||||
if (!RNA_struct_equals(a->ptr, b->ptr))
|
||||
if (!RNA_struct_equals(a->ptr, b->ptr, true))
|
||||
return 0;
|
||||
|
||||
if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE))
|
||||
@@ -874,9 +874,14 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
|
||||
}
|
||||
#endif
|
||||
|
||||
if (kmi->ptr && IDP_EqualsProperties_ex(properties, kmi->ptr->data, is_strict)) {
|
||||
if (keymap_r) *keymap_r = keymap;
|
||||
return kmi;
|
||||
if (kmi->ptr) {
|
||||
PointerRNA properties_ptr;
|
||||
RNA_pointer_create(NULL, kmi->ptr->type, properties, &properties_ptr);
|
||||
|
||||
if (RNA_struct_equals(&properties_ptr, kmi->ptr, is_strict)) {
|
||||
if (keymap_r) *keymap_r = keymap;
|
||||
return kmi;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -958,7 +963,12 @@ static wmKeyMapItem *wm_keymap_item_find(
|
||||
|
||||
RNA_pointer_create(NULL, ot->srna, properties_default, &opptr);
|
||||
|
||||
if (WM_operator_properties_default(&opptr, true)) {
|
||||
if (WM_operator_properties_default(&opptr, true) ||
|
||||
(ot->prop && RNA_property_is_set(&opptr, ot->prop))) {
|
||||
/* for operator that has enum menu, unset it so it always matches */
|
||||
if (ot->prop)
|
||||
RNA_property_unset(&opptr, ot->prop);
|
||||
|
||||
found = wm_keymap_item_find_props(C, opname, opcontext, properties_default, 0, hotkey, keymap_r);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user