From f9a3a22e9e3a1dd9801776a94a841830c9e96bd2 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Wed, 23 Jan 2013 10:38:46 +0000 Subject: [PATCH] Fix leak as reported by zmike. - Add support for AltGr key in E_Kbd_Buf_Key - Fix e_kbd_buf_layout_key_add to also take in altgr as a param. Signed-off-by: Christopher Michael SVN revision: 83153 --- src/modules/illume-keyboard/e_kbd_buf.c | 4 +++- src/modules/illume-keyboard/e_kbd_buf.h | 7 ++++--- src/modules/illume-keyboard/e_kbd_int.c | 7 ++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/modules/illume-keyboard/e_kbd_buf.c b/src/modules/illume-keyboard/e_kbd_buf.c index 452e866f0..55cd1e661 100644 --- a/src/modules/illume-keyboard/e_kbd_buf.c +++ b/src/modules/illume-keyboard/e_kbd_buf.c @@ -31,6 +31,7 @@ _e_kbd_buf_layout_unref(E_Kbd_Buf_Layout *kbl) if (ky->key) eina_stringshare_del(ky->key); if (ky->key_shift) eina_stringshare_del(ky->key_shift); if (ky->key_capslock) eina_stringshare_del(ky->key_capslock); + if (ky->key_altgr) eina_stringshare_del(ky->key_altgr); free(ky); kbl->keys = eina_list_remove_list(kbl->keys, kbl->keys); } @@ -366,7 +367,7 @@ e_kbd_buf_layout_fuzz_set(E_Kbd_Buf *kb, int fuzz) } EAPI void -e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, const char *key_capslock, int x, int y, int w, int h) +e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, const char *key_capslock, const char *key_altgr, int x, int y, int w, int h) { E_Kbd_Buf_Key *ky; @@ -378,6 +379,7 @@ e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, ky->key = eina_stringshare_add(key); if (key_shift) ky->key_shift = eina_stringshare_add(key_shift); if (key_capslock) ky->key_capslock = eina_stringshare_add(key_capslock); + if (key_altgr) ky->key_altgr = eina_stringshare_add(key_altgr); ky->x = x; ky->y = y; ky->w = w; diff --git a/src/modules/illume-keyboard/e_kbd_buf.h b/src/modules/illume-keyboard/e_kbd_buf.h index 4ba2618ff..9838d6631 100644 --- a/src/modules/illume-keyboard/e_kbd_buf.h +++ b/src/modules/illume-keyboard/e_kbd_buf.h @@ -33,7 +33,7 @@ struct _E_Kbd_Buf struct _E_Kbd_Buf_Key { int x, y, w, h; - const char *key, *key_shift, *key_capslock; + const char *key, *key_shift, *key_capslock, *key_altgr; }; struct _E_Kbd_Buf_Keystroke @@ -45,7 +45,8 @@ struct _E_Kbd_Buf_Keystroke unsigned char capslock : 1; }; -struct _E_Kbd_Buf_Layout { +struct _E_Kbd_Buf_Layout +{ int ref; int w, h; int fuzz; @@ -59,7 +60,7 @@ EAPI void e_kbd_buf_clear(E_Kbd_Buf *kb); EAPI void e_kbd_buf_layout_clear(E_Kbd_Buf *kb); EAPI void e_kbd_buf_layout_size_set(E_Kbd_Buf *kb, int w, int h); EAPI void e_kbd_buf_layout_fuzz_set(E_Kbd_Buf *kb, int fuzz); -EAPI void e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, const char *key_capslock, int x, int y, int w, int h); +EAPI void e_kbd_buf_layout_key_add(E_Kbd_Buf *kb, const char *key, const char *key_shift, const char *key_capslock, const char *key_altgr, int x, int y, int w, int h); EAPI void e_kbd_buf_pressed_key_add(E_Kbd_Buf *kb, const char *key, int shift, int capslock); EAPI void e_kbd_buf_pressed_point_add(E_Kbd_Buf *kb, int x, int y, int shift, int capslock); EAPI const char *e_kbd_buf_actual_string_get(E_Kbd_Buf *kb); diff --git a/src/modules/illume-keyboard/e_kbd_int.c b/src/modules/illume-keyboard/e_kbd_int.c index 842a2414e..713826ff9 100644 --- a/src/modules/illume-keyboard/e_kbd_int.c +++ b/src/modules/illume-keyboard/e_kbd_int.c @@ -112,21 +112,22 @@ _e_kbd_int_layout_buf_update(E_Kbd_Int *ki) } if (out) { - char *s1 = NULL, *s2 = NULL, *s3 = NULL; + char *s1 = NULL, *s2 = NULL, *s3 = NULL, *s4 = NULL; if ((out) && (out[0] == '"')) s1 = strdup(_e_kbd_int_str_unquote(out)); if ((out_shift) && (out_shift[0] == '"')) s2 = strdup(_e_kbd_int_str_unquote(out_shift)); if ((out_altgr) && (out_altgr[0] == '"')) - s2 = strdup(_e_kbd_int_str_unquote(out_altgr)); + s4 = strdup(_e_kbd_int_str_unquote(out_altgr)); if ((out_capslock) && (out_capslock[0] == '"')) s3 = strdup(_e_kbd_int_str_unquote(out_capslock)); - e_kbd_buf_layout_key_add(ki->kbuf, s1, s2, s3, + e_kbd_buf_layout_key_add(ki->kbuf, s1, s2, s3, s4, ky->x, ky->y, ky->w, ky->h); free(s1); free(s2); free(s3); + free(s4); } } }