RE: Getting segmentation faults when setting text



The code looks ok assuming that text_entry_box is set to point to the gtkentry
in question prior to the call to gtk_signal_connect().  You might want to change
(GtkWidget *)text_entry_box to GTK_WIDGET(text_entry_box) to take advantage of
GTK's runtime error checking to make sure that text_entry_box is indeed pointing
to a gtkwidget before casting it into one.  In short, the former will force a
recasting of text_entry_box, the latter will check to make sure it's ok to
recast the variable before recasting it and send you a warning message if
something is wrong.



				-- Stupid Genius

> ----------
> From: 	cedwards rbdc com[SMTP:cedwards rbdc com]
> Sent: 	Thursday, October 05, 2000 9:05 PM
> To: 	gtk-list gnome org
> Subject: 	Getting segmentation faults when setting text
> 
> Greetings,
> In my program, I have a button that the user clicks to reset the text in
> a text-entry area. When the button
> is clicked, the handler I've written is supposed to set the text to
> "default", but it causes a seg fault when I
> click the button.
> Here's the code that's relevant:
> 
> void reset_text(GtkWidget *widget, gpointer text_entry_box) {
>   gtk_entry_set_text(GTK_ENTRY((GtkWidget *)text_entry_box), "default");
> 
> }
> 
> gtk_signal_connect(GTK_OBJECT(reset_button), "clicked",
> GTK_SIGNAL_FUNC(reset_text),
>                             text_entry_box);
> 
> What exactly am I doing wrong, and what should I do to fix it?
> 
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]