g_object_get() returns a string copy, so the caller has to free it. Found by valgrind. --- Review appreciated.
src/ui/gui/psppire-window-base.c | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ui/gui/psppire-window-base.c b/src/ui/gui/psppire-window-base.c index 29c0fd7..328b92e 100644 --- a/src/ui/gui/psppire-window-base.c +++ b/src/ui/gui/psppire-window-base.c @@ -42,16 +42,21 @@ G_DEFINE_ABSTRACT_TYPE (PsppireWindowBase, psppire_window_base, GTK_TYPE_WINDOW) If the window has a name, we use that. Otherwise we fall back on the class name. + + The caller must free the returned string, with g_free(). */ -static const char * +static gchar * get_window_id (GtkWidget *wb) { - const gchar *name = NULL; - + gchar *name = NULL; + g_object_get (wb, "name", &name, NULL); if (NULL == name || 0 == strcmp ("", name)) - name = G_OBJECT_TYPE_NAME (wb); + { + g_free (name); + name = g_strdup (G_OBJECT_TYPE_NAME (wb)); + } return name; } @@ -64,8 +69,11 @@ static void realize (GtkWidget *wb) { PsppireConf *conf = psppire_conf_new (); + gchar *id; - psppire_conf_set_window_geometry (conf, get_window_id (wb), GTK_WINDOW (wb)); + id = get_window_id (wb); + psppire_conf_set_window_geometry (conf, id, GTK_WINDOW (wb)); + g_free (id); if (GTK_WIDGET_CLASS (psppire_window_base_parent_class)->realize) return GTK_WIDGET_CLASS (psppire_window_base_parent_class)->realize (wb) ; @@ -81,8 +89,11 @@ configure_event (GtkWidget *wb, GdkEventConfigure *event) if (gtk_widget_get_mapped (wb)) { PsppireConf *conf = psppire_conf_new (); + gchar *id; - psppire_conf_save_window_geometry (conf, get_window_id (wb), GTK_WINDOW (wb)); + id = get_window_id (wb); + psppire_conf_save_window_geometry (conf, id, GTK_WINDOW (wb)); + g_free (id); } if (GTK_WIDGET_CLASS (psppire_window_base_parent_class)->configure_event) -- 1.7.2.5 _______________________________________________ pspp-dev mailing list pspp-dev@gnu.org https://lists.gnu.org/mailman/listinfo/pspp-dev