Re: Seg Fault on NULL strlen
- From: Steve & Patti Getzinger <psatg bluemarble net>
- To: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: Seg Fault on NULL strlen
- Date: Sun, 29 Dec 2002 12:48:20 -0500
Steve & Patti Getzinger wrote:
Patrice St-Gelais wrote:
Signal connects all are listed at the end of window configs so entry2
is already created. Is there a way for me to tap the entries involved
and do an if based on changed? I am not controlling the order entries
are made so I need to be able to tap all 3 as all three need entries.
This way if it has not been touched (changed) we exit the func with a
false setting for sensitivity. If it has we check for size of entry
Check if "entry2" is defined the first time "on_entry1_changed" is
Maybe the callback is activated when you initialize the value of entry1,
before creating entry2, or something like this.
If it's the case, inserting a test to get out of the callback if
NULL, before casting it with GTK_EDITABLE, would solve the seg
fault. If I
understand your code and your explanation, "entry1" shouldn't be NULL at
this point, and should be equal to "editable" because
connected to "entry1".
Steve & Patti Getzinger a écrit :
I am attempting to set sensitivity based on entries in 3 entry
basically the first is easy. I am hitting a func on changed of
the func I am doing an
on_entry1_changed (GtkEditable *editable,
if(strlen(gtk_editable_get_chars(GTK_EDITABLE(entry1),0,-1)) > 7)
if(strlen(gtk_editable_get_chars(GTK_EDITABLE(entry2),0,-1)) > 0)
gtk_widget_set_sensitive (button1, TRUE);
gtk_widget_set_sensitive (button1, FALSE);
With this config it seg faults with:
(gdiald:16598): GLib-GObject-WARNING **: invalid cast from (NULL)
pointer to `GtkEditable'
(gdiald:16598): Gtk-CRITICAL **: file gtkeditable.c: line 125
(gtk_editable_get_chars): assertion `GTK_IS_EDITABLE (editable)'
I am assuming strlen returns NULL if there has been no entry made in
entry2. How do I get around this one?
I recently added:
which stops the seg fault but still get editable is not editable error.
I have change on entry2 set to hit the changed func of entry1 so even if
the error is thrown while entering in entry1 when I switch to entering
in entry2 and entery is above NULL shouldn't it possibly recognize it?
What do I need to look for that makes entry2 seen as editable? Why is
NULL not a valid pointer? How do I get around this?
] [Thread Prev