Re: gtk-entry pointer problem
- From: Iago Rubio <iago rubio hispalinux es>
- To: gtk-app-devel-list gnome org
- Subject: Re: gtk-entry pointer problem
- Date: Thu, 10 Mar 2005 12:53:55 +0100
On Wed, 2005-03-09 at 11:19 +0100, simon honold epfl ch wrote:
Hello,
I have a problem with my gtk entry widget. In my application I want to get the
path of a picture, entered by the user in this entry widget.
I have the following structure which is passed as argument
[snipped]
gboolean text_path_drawback(GtkWidget*widget,GdkEvent *event,struct picture_s
*picture){
const char *pathentered= gtk_entry_get_text (GTK_ENTRY (widget));
picture->path=pathentered;
printf("%sn",picture->path);
return TRUE;
}
so this printf is done very well, but if I click now on my Load button widget
and i use absolutely the same printf,( printf("%sn",picture->path); )
so my element "path" seems to be a null pointer.
const char *pathentered is out of bounds when it runs out the function.
Try to chage:
gtk_entry_get_text(GTK_ENTRY (widget))
.. with ...
gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1)
It returns an allocated buffer - you should remember to free it - and
will not get out of bounds when this function ends.
[snip]
I now, that it has to be a really stupid beginner mistake, but i can't find it,
so please help me a little bit!!
I hope I did :)
--
Iago Rubio
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]