add text to entry fails. g_snprintf bad?
- From: edward hage <edha xs4all nl>
- To: gtk-list gnome org
- Subject: add text to entry fails. g_snprintf bad?
- Date: Wed, 09 Jun 2004 21:33:23 +0200
I want to fill in an entry text with a double value from an variable named som.stepsize,
for example this value is som.stepsize = 0,001 and is defined as global so always available.
To add text I need a string so I use g_snprintf to create this string and then add it to
the entry.
All kind of straightforward, but I have real big difficulties getting it right. I keep
getting Segmentation errors.
Oh, I also tried sprintf (from stdio.h), but this did not help. Also tried g_strdup_printf
but then I got more problems with not being UTF-8 text, so I got strange ASCII-letters.
I think it must be some combination that gives the error, because when I g_print("%f
\n",labeltext1) after the g_snprintf this gives the correct value (before Segmentation
error occurs). But when I delete g_snprintf then the problem is solved ?
Also it seems that compiling sometimes does function, and not a next time, or am I getting
paranoid over this. It has been bothering me for all day and evening.
By the way, I am using gtk+-2.0.
g_snprintf(labeltext1, 6, "%f", sim.stepsize);
void Create_tab_sim (GtkWidget *tabnumber)
GtkWidget *stepsz;
gchar *labeltext1;
// defined table and other widgets here, cropped it
stepsz = gtk_entry_new ();
gtk_table_attach_defaults (GTK_TABLE (table), stepsz, 1, 2, 0, 1);
g_signal_connect (GTK_OBJECT(stepsz), "activate", (GCallback) simulation_event,
GINT_TO_POINTER (STEPSIZE));
gtk_entry_set_max_length ((GtkEntry *)stepsz, 6);
g_snprintf(labeltext1, 6, "%f", sim.stepsize); <----------
gtk_entry_set_text (( GtkEntry *)stepsz, labeltext1); <----------
// more data here , cropped it
g_free(labeltext1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]