RE: newbie trap



Ross Clement wrote:
Hi. I find myself writing a program that processes the gtk gui events
itself. E.g. code vaguely similar to the pseudo-code:

while( large_compute_bound_job_not_finished )
{
  process_next_block_of_data();
  gtk_progress_bar_set_fraction( progressBar, fraction );
  
  while ( gtk_events_pending ())
          gtk_main_iteration ();
}

Is this something that it is frequently sensible to do, or have I fallen
into a big newbie trap?

I'm not sure I understand you correctly, but one thing to think about is reentrance; are the screen update 
functions reeantrant? I remember from my Windows days (now happily in the remote past) that anything to do 
with the desktop was not reentrant. What that means is that you can not update the screen from anything other 
than the main thread; I have got used to simply avoiding that, so I don't know if X can handle it.

One trap Windows programmers always used to fall in was to update a progress indicator whenever a network 
packet arrived; this went well as long as the update managed to return before the next packet arrived, but it 
caused intermittent errors and crashes when the load got too big.

/jan



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