HELP! gtk_entry_set_text and gtk_label_set_text cannot be called rapidly.



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():
	... ...
		for (i = 0; i < NUM_SENSORS; i++){
 	               g_sprintf(str, "%d",
  	                              (gClient_rcv_data.gSensorData.sensor_value[i] / get_div(i)));
	
 	               gtk_entry_set_text((GtkEntry *)sensor_display[i], str);
  	      }
	return true;
	}

I found that the program crashes in few seconds everytime it is executed. GDB gives me the following error message:

	Program received signal SIGSEGV, Segmentation fault.
	0x400ccf19 in gtk_entry_set_text () from /usr/lib/libgtk-x11-2.0.so.0

I tried to use Labels instead of Entries in the GUI, but still got the same problem.

Can anyone help me?

skybird 163 com



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