Re: HELP! gtk_entry_set_text and gtk_label_set_text cannot be called rapidly.



On Tuesday 12 August 2003 02:45, Colin Walters wrote:
> On Mon, 2003-08-11 at 17:22, wangxiaohu wrote:
> > I am new to GTK+.
> >
> > I wrote a program which updates statistics data every 100 milliseconds.
> >
> > I use g_timeout_add() to do this:
> >
> > 	timeout_handler = g_timeout_add(100, gSensor_receive, NULL);
> >
> > and in gSensor_receive():
>
> Are you grabbing the GDK lock here?  Make sure you're using
> GDK_THREADS_ENTER (); and GDK_THREADS_LEAVE ();

g_sprintf() is the problem here, not grabbing the GDK lock (since this isn't a 
multithreaded program).

> g_sprintf(str, "%d",  (gClient_rcv_data.gSensorData.sensor_value[i] / 
get_div(i)));

Is str a static buffer? How big is it? You may have overflowed the buffer when  
(gClient_rcv_data.gSensorData.sensor_value[i] / get_div(i)) gets too big.
Try the following code instead:

gchar *str = g_strdup_printf ("%d", (something / somethingElse));
gtk_entry_set_text (entry, str);
g_free (str);



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