diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-11-01 00:29:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-11-01 00:29:32 +0400 |
commit | 1bcadda46b96e3e557aad1b0d2d53a0b4743b413 (patch) | |
tree | 3f749a30df330ced48905860da40b1ed21254f6e /source/blender/blenkernel/intern | |
parent | 26541afc8b9bfa0b11ecd2dcdab120cfcfff5d92 (diff) |
fix [#30910] Problems: Add Shortcut(s) for "Ctrl Tab" menu
comparing keymaps was too sloppy or too strict, now sloppy keymap comparison works by setting all the operator
properties to their default values if they are not already set, then compare this with the keymap item (ignoring values missing from either one).
... this way any non default keymap setting wont match with an operator menu item which doesnt set this operator at all (a problem sighted in this bug report).
developer notes:
- IDP_EqualsProperties_ex() function adds an argument to treat missing members of either group to act as if there is a match.
- WM_operator_properties_default() function to reset RNA values to their defaults.
- add IDP_spit(), debug only function to print out ID properties.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 584de4cd982..5dd0f08dc71 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -632,12 +632,14 @@ IDProperty *IDP_GetProperties(ID *id, int create_if_needed) } } -int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) +/** + * \param is_strict When FALSE treat missing items as a match */ +int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict) { if (prop1 == NULL && prop2 == NULL) return 1; else if (prop1 == NULL || prop2 == NULL) - return 0; + return is_strict ? 0 : 1; else if (prop1->type != prop2->type) return 0; @@ -661,13 +663,13 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) { IDProperty *link1, *link2; - if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group)) + if (is_strict && BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group)) return 0; for (link1 = prop1->data.group.first; link1; link1 = link1->next) { link2 = IDP_GetPropertyFromGroup(prop2, link1->name); - if (!IDP_EqualsProperties(link1, link2)) + if (!IDP_EqualsProperties_ex(link1, link2, is_strict)) return 0; } @@ -696,6 +698,11 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) return 1; } +int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) +{ + return IDP_EqualsProperties_ex(prop1, prop2, TRUE); +} + /* 'val' is never NULL, don't check */ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) { |