Re: [gtk-list] problems with gtk_entry_get_text




On Sun, 31 May 1998, Travis Loyd wrote:
> 
> While I am asking, there is a reason for that 'before', if I remove the
> comment here:
> 
>         g_print("before[packet]%s\n", newtext);
>         gtk_text_insert(GTK_TEXT(ptr->chat_display_text), NULL, NULL,
> 			NULL, newtext, strlen(newtext));
> //      g_print(" after[packet]%s\n", newtext);
> 
> garbage is displayed as if gtk_text_insert corrupts `newtext'?
> 

The problem is probably that the _get_text functions don't return a
dynamically allocated string, they return a pointer to their own internal
data. So you need to g_strdup the string you get back if you want to
modify the text widget (unless you finish with the string before any text
widget mods). And of course you should g_strdup if you want to modify the
string, and you should be sure you don't g_free the text widget's string. 

That's my guess.

Havoc Pennington ==== http://pobox.com/~hp




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