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:
authorCampbell Barton <ideasman42@gmail.com>2012-01-22 02:42:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-22 02:42:09 +0400
commit83b1f21cf9454cbbe49411b8973d57b5c9f76642 (patch)
tree2c7a141bff4b800d49d6b729cc13de897c4d6330 /source/blender/editors/interface/interface_handlers.c
parentb95beea539b22baeb68013c4e65fb0455b968890 (diff)
fix for memory leak displaying shortcuts to buttons which use allocated string, also de-duplocate this code which had this error in 2 places.
noticed while testing 1023 length paths.
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 311f0f87b50..93d8f9c0c8a 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4382,31 +4382,19 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
uiBut *but = (uiBut *)arg1;
if (but->optype) {
- char buf[512], *cpoin;
+ char shortcut_str[128];
IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
/* complex code to change name of button */
if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
- buf, sizeof(buf)))
+ shortcut_str, sizeof(shortcut_str)))
{
- char *butstr_orig;
-
- // XXX but->str changed... should not, remove the hotkey from it
- cpoin= strchr(but->str, '|');
- if(cpoin) *cpoin= 0;
-
- butstr_orig= BLI_strdup(but->str);
- BLI_snprintf(but->strdata, sizeof(but->strdata), "%s|%s", butstr_orig, buf);
- MEM_freeN(butstr_orig);
- but->str= but->strdata;
-
- ui_check_but(but);
+ ui_but_add_shortcut(but, shortcut_str, TRUE);
}
else {
- /* shortcut was removed */
- cpoin= strchr(but->str, '|');
- if(cpoin) *cpoin= 0;
+ /* simply strip the shortcut */
+ ui_but_add_shortcut(but, NULL, TRUE);
}
}
}