pidgin/pidgin

Fix pidgin_prefs_dropdown

2021-02-25, Arkadiy Illarionov
65dbbd384c8e
Parents 3c037af432c4
Children 1ea760e56414
Fix pidgin_prefs_dropdown

`menuitems` in `pidgin_prefs_dropdown_from_list` should have `PurpleKeyValuePair` element type.

Testing Done:
Compile and run.

Reviewed at https://reviews.imfreedom.org/r/526/
--- a/pidgin/gtkprefs.c Thu Feb 25 03:49:17 2021 -0600
+++ b/pidgin/gtkprefs.c Thu Feb 25 20:44:26 2021 -0600
@@ -573,25 +573,20 @@
GList *menuitems = NULL;
GtkWidget *dropdown = NULL;
char *name;
- int int_value;
- const char *str_value;
g_return_val_if_fail(type == PURPLE_PREF_BOOLEAN || type == PURPLE_PREF_INT ||
type == PURPLE_PREF_STRING, NULL);
va_start(ap, key);
while ((name = va_arg(ap, char *)) != NULL) {
-
- menuitems = g_list_prepend(menuitems, name);
+ PurpleKeyValuePair *kvp;
if (type == PURPLE_PREF_INT || type == PURPLE_PREF_BOOLEAN) {
- int_value = va_arg(ap, int);
- menuitems = g_list_prepend(menuitems, GINT_TO_POINTER(int_value));
+ kvp = purple_key_value_pair_new(name, GINT_TO_POINTER(va_arg(ap, int)));
+ } else {
+ kvp = purple_key_value_pair_new(name, va_arg(ap, char *));
}
- else {
- str_value = va_arg(ap, const char *);
- menuitems = g_list_prepend(menuitems, (char *)str_value);
- }
+ menuitems = g_list_prepend(menuitems, kvp);
}
va_end(ap);
@@ -602,7 +597,7 @@
dropdown = pidgin_prefs_dropdown_from_list(box, title, type, key,
menuitems);
- g_list_free(menuitems);
+ g_list_free_full(menuitems, (GDestroyNotify)purple_key_value_pair_free);
return dropdown;
}