Re: gtk_entry_get_text + strange Segmentation fault



On 12/5/01 2:25 PM, "Marc Bruenink" <marc bruenink de> wrote:

cBuffer = gtk_entry_get_text(GTK_ENTRY(input));

free(cBuffer);

[...]

If i comment 
cBuffer = gtk_entry_get_text(GTK_ENTRY(configInput1));
out, everything works fine. But if i use this line i get a "Segmentation
fault" AFTER correct execution of win::WindowOKButtonClicked.
I've no $%&/ clue why this appears.
Any suggestions??

Don't free the result of gtk_entry_get_text. As it says on this page
<http://developer.gnome.org/doc/API/gtk/gtkentry.html>: "The returned
pointer points to internally allocated storage in the widget and must not be
freed, modified or stored. For this reason, this function is deprecated. Use
gtk_editable_get_chars() instead."

Also, if you are going to free something from gtk, you have to use g_free(),
not free(), although you can "get away" with calling free() if you don't
ever use any interesting debugging modes.

    -- Darin




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