From 02a5cf75a21ba0aeb394b3ff0b9882f950187adc Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 10 Apr 2015 11:03:47 -0300 Subject: Fix for debug-only crash when setting "Any" keymap input type Another one of those assert crashes when passing values != than 1 and 0 (in this case the value is -1) Notes from reviewer: -------------------- These should really be enums. since valid values are KM_ANY, KM_MOD_FIRST, KM_MOD_SECOND. But can see at some point this was changed from an enum so... I guess this is the only way. Reviewers: campbellbarton Differential Revision: https://developer.blender.org/D1227 --- source/blender/makesrna/intern/rna_wm.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source/blender/makesrna/intern') diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index a423a069517..f01e1d02028 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -790,6 +790,29 @@ static void rna_KeyMapItem_any_set(PointerRNA *ptr, int value) } } +static int rna_KeyMapItem_shift_get(PointerRNA *ptr) +{ + wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; + return kmi->shift != 0; +} + +static int rna_KeyMapItem_ctrl_get(PointerRNA *ptr) +{ + wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; + return kmi->ctrl != 0; +} + +static int rna_KeyMapItem_alt_get(PointerRNA *ptr) +{ + wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; + return kmi->alt != 0; +} + +static int rna_KeyMapItem_oskey_get(PointerRNA *ptr) +{ + wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data; + return kmi->oskey != 0; +} static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr) { @@ -2073,6 +2096,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shift", 0); + RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_shift_get", NULL); /* RNA_def_property_enum_sdna(prop, NULL, "shift"); */ /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */ RNA_def_property_ui_text(prop, "Shift", "Shift key pressed"); @@ -2080,6 +2104,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0); + RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_ctrl_get", NULL); /* RNA_def_property_enum_sdna(prop, NULL, "ctrl"); */ /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */ RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed"); @@ -2087,6 +2112,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "alt", 0); + RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_alt_get", NULL); /* RNA_def_property_enum_sdna(prop, NULL, "alt"); */ /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */ RNA_def_property_ui_text(prop, "Alt", "Alt key pressed"); @@ -2094,6 +2120,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0); + RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_oskey_get", NULL); /* RNA_def_property_enum_sdna(prop, NULL, "oskey"); */ /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */ RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed"); -- cgit v1.2.3