leak--: Store xkb_rule_names into Input structure so we can free the strings

on shutdown or keymap change.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2013-06-27 11:37:51 +01:00
parent fa9104b305
commit 87c1798281
2 changed files with 18 additions and 8 deletions

View File

@ -74,7 +74,7 @@ static Eina_Bool _e_comp_wl_input_init(void);
static void _e_comp_wl_input_shutdown(void);
static void _e_comp_wl_input_cb_bind(struct wl_client *client, void *data, unsigned int version EINA_UNUSED, unsigned int id);
static void _e_comp_wl_input_cb_unbind(struct wl_resource *resource);
static struct xkb_keymap *_e_comp_wl_input_keymap_get(void);
static struct xkb_keymap *_e_comp_wl_input_keymap_get(E_Wayland_Input *input);
static int _e_comp_wl_input_keymap_fd_get(off_t size);
static E_Wayland_Keyboard_Info *_e_comp_wl_input_keyboard_info_get(struct xkb_keymap *keymap);
@ -1513,12 +1513,18 @@ _e_comp_wl_cb_keymap_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void
struct xkb_keymap *keymap;
/* try to fetch the keymap */
if (!(keymap = _e_comp_wl_input_keymap_get()))
if (!(keymap = _e_comp_wl_input_keymap_get(_e_wl_comp->input)))
return ECORE_CALLBACK_PASS_ON;
/* destroy keyboard */
if (_e_wl_comp->input->xkb.info)
{
free((char *)_e_wl_comp->input->xkb.names.rules);
free((char *)_e_wl_comp->input->xkb.names.model);
free((char *)_e_wl_comp->input->xkb.names.layout);
free((char *)_e_wl_comp->input->xkb.names.variant);
free((char *)_e_wl_comp->input->xkb.names.options);
/* if we have a keymap, unreference it */
if (_e_wl_comp->input->xkb.info->keymap)
xkb_map_unref(_e_wl_comp->input->xkb.info->keymap);
@ -1762,7 +1768,7 @@ _e_comp_wl_input_init(void)
_e_wl_comp->xkb.context = xkb_context_new(0);
/* try to fetch the keymap */
if ((keymap = _e_comp_wl_input_keymap_get()))
if ((keymap = _e_comp_wl_input_keymap_get(_e_wl_comp->input)))
{
/* try to create new keyboard info */
_e_wl_comp->input->xkb.info =
@ -1816,6 +1822,12 @@ _e_comp_wl_input_shutdown(void)
/* destroy keyboard */
if (_e_wl_comp->input->xkb.info)
{
free((char *)_e_wl_comp->input->xkb.names.rules);
free((char *)_e_wl_comp->input->xkb.names.model);
free((char *)_e_wl_comp->input->xkb.names.layout);
free((char *)_e_wl_comp->input->xkb.names.variant);
free((char *)_e_wl_comp->input->xkb.names.options);
/* if we have a keymap, unreference it */
if (_e_wl_comp->input->xkb.info->keymap)
xkb_map_unref(_e_wl_comp->input->xkb.info->keymap);
@ -1893,7 +1905,7 @@ _e_comp_wl_input_cb_unbind(struct wl_resource *resource)
}
static struct xkb_keymap *
_e_comp_wl_input_keymap_get(void)
_e_comp_wl_input_keymap_get(E_Wayland_Input *input)
{
E_Config_XKB_Layout *kbd_layout;
struct xkb_rule_names names;
@ -1940,10 +1952,7 @@ _e_comp_wl_input_keymap_get(void)
}
}
printf("Keymap\n");
printf("\tRules: %s\n", names.rules);
printf("\tModel: %s\n", names.model);
printf("\tLayout: %s\n", names.layout);
input->xkb.names = names;
return xkb_map_new_from_names(_e_wl_comp->xkb.context, &names, 0);
}

View File

@ -421,6 +421,7 @@ struct _E_Wayland_Input
{
E_Wayland_Keyboard_Info *info;
struct xkb_state *state;
struct xkb_rule_names names;
} xkb;
struct