diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-03-26 11:02:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-03-26 11:11:50 +0300 |
commit | e8dd96516c60c4c43c8eb217f2c2cc61761cd0a0 (patch) | |
tree | caca01d39d7072747bc2f6a3ea1046ef15715ee6 /source/blender/makesrna/intern/rna_wm_api.c | |
parent | 03b2fc1a615b442902a6565b27b73d1c5bf4ecbe (diff) |
Keymap: disallow modal key-maps in add-ons keyconfig
Disable functionality reported in T60766 & only partially worked.
This could be used if the key-map was added after Blender started
as a way to customize modal key-maps, however it didn't work with
the add-on enabled on startup.
Add-on key-maps are intended to extend existing key-maps
so they can call the add-on, not as a way to change modal key-maps
for Blender's built-in functionality.
Disable this since it's not needed as add-ons
can't yet define modal key-maps.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_api.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index df6abecd365..f1e3a999935 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -392,9 +392,27 @@ static PointerRNA rna_KeyMap_item_match_event(ID *id, wmKeyMap *km, bContext *C, return kmi_ptr; } -static wmKeyMap *rna_keymap_new( - wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, bool modal, bool tool) +static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, + ReportList *reports, + const char *idname, + int spaceid, + int regionid, + bool modal, + bool tool) { + if (modal) { + /* Sanity check: Don't allow add-ons to override internal modal key-maps + * because this isn't supported, the restriction can be removed when + * add-ons can define modal key-maps. + * Currently this is only useful for add-ons to override built-in modal keymaps + * which is not the intended use for add-on keymaps. */ + wmWindowManager *wm = G_MAIN->wm.first; + if (keyconf == wm->addonconf) { + BKE_reportf(reports, RPT_ERROR, "Modal key-maps not supported for add-on key-config"); + return NULL; + } + } + wmKeyMap *keymap; if (modal == 0) { @@ -1180,6 +1198,7 @@ void RNA_api_keymaps(StructRNA *srna) PropertyRNA *parm; func = RNA_def_function(srna, "new", "rna_keymap_new"); /* add_keymap */ + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_string(func, "name", NULL, 0, "Name", ""); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); RNA_def_enum(func, "space_type", rna_enum_space_type_items, SPACE_EMPTY, "Space Type", ""); |