gtk_timeout_add() wierdness



Hi,

I'm a new gtk programmer and having a stabge problem when using
gtk_timeout_add().  I am calling gtk_timeout_add() with:

timer = gtk_timeout_add( 1000, (GtkFunction) update_sensor_data,
            (gpointer) data );

My update function looks like:

gint update_sensor_data( gpointer data ) {
    double featureresult = 0;
    char *afeatresult;
    updates *updata = data;

    g_print( "Updating data.\n\n" );

    if ( sensors_get_feature( updata->name, updata->featnum,
         &featureresult ) != 0 ) {
        fprintf( stderr, "Getting feature info failed.\n" );
    }
    sprintf( afeatresult, "%f", featureresult );
    gtk_entry_set_text( GTK_ENTRY (updata->widget), afeatresult );

    return (TRUE);
}

With this setup gtk will execute the function only once.  This is not the
desired behavior as I want it to continue to repeat.  I have found that if
I staticly set afeatresult = 0 and remove the sprintf function, it repeats
as desired.  What's going on?  How do I fix this?

Please reply to me personally as I am not a regular list member.

Thanks,
Kris Kersey
augustus linuxhardware org




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