Re: gtk_label_get_text() string duping



Tim Janik <timj@gtk.org> writes:

> i don't hate you, in fact you're right ;)
> just "const" can be a pain in the ass for C programers as some
> code const-correct and others don't. those that do will use
> 
> const char *my_label = gtk_label_get_text (foo);
> 
> and are fine, while those that don't will do:
> 
> char *my_label = gtk_label_get_text (foo);
> 
> and get a warning if gtk_label_get_text() returns const gchar*.

Well, in that case it is tough luck for them.  I prefer to provide an
API that is as self-documenting as possible, and moreover correct,
than an API that caters to lazy users :-)

> > As Owen pointed out this has issues with threading, but hey, what the
> > hell :-)
> 
> that's a problem only occouring at the glib level and only needs to
> be solved _there_ ;)

Say two threads have a pointer to the label.

	Thread 1 is scheduled:

		const char *s = gtk_label_get_text (label);

	Thread 2 is scheduled:

		gtk_label_set_text (label, "squawk");

	Thread 1 is scheduled:

		printf ("%s is not what I think it is\n", s);

I guess that is the application's problem, anyways, since it is
futzing with the label on more than one thread.

  Federico




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