Re: gtk_entry and "changed" signal in gtk+-2.0



Owen Taylor wrote:

It's still an "official" signal, on the GtkEditable interface:

 http://developer.gnome.org/doc/API/2.0/gtk/gtk-gtkeditable.html

Is it also still an official signal of the GtkEntry interface?

 http://bugzilla.gnome.org/show_bug.cgi?id=64998

Ok. I see.

[ What if the user deleted the text and typed something else in? I don't think
  it should be a huge problem for most apps if the contents of an entry are
  temporarily in an empty state. ]

This is a problem when you do the following:

static gchar *text;

entry_changed_callback(GtkEntry *entry, void *data)
{
  if (text)
    free(text)

  text = strdup(gtk_entry_get_text(entry));
}


main()
{
...
text=strdup("Hello"); /* this is the global defined *text */
gtk_entry_set_text(entry, text);
...
}


The problem is that the first callback frees the memory in which
the text "Hello" is stored, in the second callback the text
is not available any more.

The fix is as simple as ugly ;-)

Thanks for the information.

Bye
Oliver



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