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



On Tue, 12 Aug 2003 10:37:09 +0200
Hongli Lai <h lai chello nl> wrote:

> 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  
char str[256];
> (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);
I solved the problem in another way:
I declared the entry-widgets inside gSensor_receive() instead of declaring them globally.
so that the memory is released every time it returns.
I haven't tried your suggestion, and I will later.

> _______________________________________________
> desktop-devel-list mailing list
> desktop-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/desktop-devel-list





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