Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_keymap.c')
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 3739462ac2c..20e715c18d0 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -126,10 +126,13 @@ static int wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b)
/* properties can be NULL, otherwise the arg passed is used and ownership is given to the kmi */
void WM_keymap_properties_reset(wmKeyMapItem *kmi, struct IDProperty *properties)
{
- WM_operator_properties_free(kmi->ptr);
- MEM_freeN(kmi->ptr);
+ if (LIKELY(kmi->ptr)) {
+ WM_operator_properties_free(kmi->ptr);
+ MEM_freeN(kmi->ptr);
+
+ kmi->ptr = NULL;
+ }
- kmi->ptr = NULL;
kmi->properties = properties;
wm_keymap_item_properties_set(kmi);
@@ -734,6 +737,24 @@ wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km, int type, int val, int m
return kmi;
}
+wmKeyMapItem *WM_modalkeymap_find_propvalue(wmKeyMap *km, const int propvalue)
+{
+
+ if (km->flag & KEYMAP_MODAL) {
+ wmKeyMapItem *kmi;
+ for (kmi = km->items.first; kmi; kmi = kmi->next) {
+ if (kmi->propvalue == propvalue) {
+ return kmi;
+ }
+ }
+ }
+ else {
+ BLI_assert(!"called with non modal keymap");
+ }
+
+ return NULL;
+}
+
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0);
@@ -782,7 +803,7 @@ const char *WM_key_event_string(short type)
return "";
}
-char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
+int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
{
char buf[128];
@@ -815,9 +836,7 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
}
strcat(buf, WM_key_event_string(kmi->type));
- BLI_strncpy(str, buf, len);
-
- return str;
+ return BLI_strncpy_rlen(str, buf, len);
}
static wmKeyMapItem *wm_keymap_item_find_handlers(