X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fpsppire-encoding-selector.c;h=536f3a595243ff8cb7459833dccf44f6cf4a8b80;hb=ab7933960a09a9e1d3ca9a119e11b92a7cff6769;hp=82677d8f59005660190be372b593f52bdf0327d2;hpb=e4e0d0fdf07ad9b9b2790630ff3f9a458919735f;p=pspp diff --git a/src/ui/gui/psppire-encoding-selector.c b/src/ui/gui/psppire-encoding-selector.c index 82677d8f59..536f3a5952 100644 --- a/src/ui/gui/psppire-encoding-selector.c +++ b/src/ui/gui/psppire-encoding-selector.c @@ -183,13 +183,17 @@ psppire_encoding_selector_new (const char *default_encoding, return hbox; } +/* + Return a string describing the currently selected encoding. + The caller should free this string when no longer required. +*/ gchar * psppire_encoding_selector_get_encoding (GtkWidget *selector) { gchar *encoding = NULL; - GList *list, *pos; + GList *pos; + GList *list = gtk_container_get_children (GTK_CONTAINER (selector)); - list = gtk_container_get_children (GTK_CONTAINER (selector)); for (pos = list; pos; pos = pos->next) { GtkWidget *widget = pos->data; @@ -206,7 +210,14 @@ psppire_encoding_selector_get_encoding (GtkWidget *selector) break; } } + g_list_free (list); - return encoding && !strcmp (encoding, "Auto") ? NULL : encoding; + if (0 == strcmp (encoding, "Auto")) + { + g_free (encoding); + return NULL; + } + + return encoding; }