- utils.c: Fix gkrellm_gtk_entry_get_text() default return value (empty string was allocated on the stack and is now a proper static variable)

This commit is contained in:
Stefan Gehn 2008-09-30 14:51:48 +00:00
parent e03fa87217
commit cb4a2344eb
1 changed files with 9 additions and 6 deletions

View File

@ -239,12 +239,15 @@ gkrellm_make_home_subdir(gchar *subdir, gchar **path)
gchar * gchar *
gkrellm_gtk_entry_get_text(GtkWidget **entry) gkrellm_gtk_entry_get_text(GtkWidget **entry)
{ {
gchar *s = ""; static /*const*/ gchar *def_s = "";
gchar *s = def_s;
if (*entry) if (*entry)
s = (gchar *) gtk_entry_get_text(GTK_ENTRY(*entry)); {
while (*s == ' ' || *s == '\t') s = (gchar *)gtk_entry_get_text(GTK_ENTRY(*entry));
++s; while (*s == ' ' || *s == '\t')
++s;
}
return s; return s;
} }
@ -291,7 +294,7 @@ gkrellm_gdk_text_width(PangoFontDescription *font_desc,
pango_layout_set_text(layout, string, len); pango_layout_set_text(layout, string, len);
pango_layout_get_pixel_size(layout, &w, &h); pango_layout_get_pixel_size(layout, &w, &h);
g_object_unref(layout); g_object_unref(layout);
return w; return w;
} }
gint gint
@ -306,7 +309,7 @@ gkrellm_gdk_text_markup_width(PangoFontDescription *font_desc,
pango_layout_set_markup(layout, string, len); pango_layout_set_markup(layout, string, len);
pango_layout_get_pixel_size(layout, &w, &h); pango_layout_get_pixel_size(layout, &w, &h);
g_object_unref(layout); g_object_unref(layout);
return w; return w;
} }
gint gint