Skip to content

Commit

Permalink
Don't require plugin key group name and label strings to be static
Browse files Browse the repository at this point in the history
Take a copy of the strings not to require them to live live as long as
the plugin does.

This is mostly useful for plugins implemented in dynamic languages
(e.g. through a plugin proxy), as most C plugins will use a static
string here; but it makes the API more straightforward and avoids odd
issues if any plugin doesn't use static strings here, even C ones.

Closes #1125.
  • Loading branch information
b4n committed Jul 8, 2016
1 parent 91b6304 commit 9ba7f67
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/keybindings.c
Expand Up @@ -262,8 +262,9 @@ static void add_kb_group(GeanyKeyGroup *group,
{
g_ptr_array_add(keybinding_groups, group);

group->name = name;
group->label = label;
/* as for items, we only require duplicated name and label for plugins */
group->name = plugin ? g_strdup(name) : name;
group->label = plugin ? g_strdup(label) : label;
group->callback = callback;
group->cb_func = NULL;
group->cb_data = NULL;
Expand Down Expand Up @@ -722,6 +723,9 @@ static void free_key_group(gpointer item)
if (group->cb_data_destroy)
group->cb_data_destroy(group->cb_data);
g_free(group->plugin_keys);
/* we allocated those in add_kb_group() as it's a plugin group */
g_free((gchar *) group->name);
g_free((gchar *) group->label);
g_free(group);
}
}
Expand Down

1 comment on commit 9ba7f67

@kugel-
Copy link
Member

@kugel- kugel- commented on 9ba7f67 Jul 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.