GUI freeze by changing label from thread



Hello,

I have a thread that does try to change a label in a window. Sometimes
(nearly often) the window does "freeze". Freeze means that the window
isn't longer redrawn. So the window is empty, but it does still react
on events (e.g. mouse press). Here is a sketch of what I do:

class App : public Gtk::Window
{
  ...
  void updateLabel(string text)
  {
    label.setText (text); // -> if I comment this out all works! if not
                          //     I get a freeze
    cout << text << endl; // this isn't a problem and works everytime
  }
  ...
}

App app;

...
void MyThread ()
{
  while (1)
  {
    // generate data...
    app.updateLabel (text):
  }
}

It seems the freeze doesn't depend on the rate in which updateText() is
called. Also if I call updateText only once per three second I get the
freeze.

I've no idea at the moment why this does freeze? Could you imagine why
the GUI isn't redrawn?

regards
Andreas



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