Queue Draw does not always call expose signal



Hi There,

I'm almost done creating an application using Gtkmm, which has a drawing area (an OpenGL scene), which serves as a soon to be open sourced graph visualisation application. A big thank you to all the creators for this tool, but I'd like to ask for some help :)

The program is event driven, but has a thread running that processes the layout. Every time one iteration of the layout algorithm in the layout thread has occured, I call 'queue_draw()' on the drawing area. The drawing area has the following definition:

class RefMapGLScene : public Gtk::DrawingArea, public Gtk::GL::Widget<RefMapGLScene>

And in the constructor, I attach the expose_event signal as follows:

 signal_expose_event().connect(sigc::mem_fun(*this, &RefMapGLScene::my_expose_event));

Which is implemented as so:

bool RefMapGLScene::my_expose_event(GdkEventExpose* event) {
  cout << "exposed" << endl;
  pthread_mutex_lock(&parent->gtkLock);
  redraw();
  Gtk::DrawingArea::on_expose_event(event);
  pthread_mutex_unlock(&parent->gtkLock);
  return true;
}

A quick explanation. The parent is the window that holds this widget/drawing area. The redraw() function actually does all the redrawing.

Now, my issue is that when I call queue_draw() in my layout thread, it will continually send the expose_event signal, up until a point. Eventually (anywhere from 10-1000 queue_draw()'s), the my_expose_event() function will stop being called. I have other parts of my program, say, right clicking that will lead it to change the status bar text, if I call this, it (usually!) fixes it. Same thing if I use the menubar. However, the problem will occur after a certain number of iterations calling the queue_draw() again. It sounds like something is happening to corrupt the event queue, but I can't figure out what... I also can't figure out why after a random number of cycles, the expose signal would not be sent. I have also tried to override the on_expose_event() function instead of attaching the signal, but that results in the same problem.

I would greatly appreciate any suggestions.

Cheers,

Simon


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