Travis Martin
Travis Martin

Reputation: 51

Repeated window invalidation in GTK+: failure after several steps

I have a timer which calls a method (perform_step) every second. perform_step does some computation and invalidates my window. This works well initially but after a small number of iterations the on_expose_event of the window isn't triggered. From debugging I discovered the window invalidation method had been called, but the event handler isn't entered.

Any ideas what might cause this? Here are some things I've discovered that might be helpful:

Here a code snippet:

bool SimDisplay::on_button_press_event(GdkEventButton* event) {
  Glib::signal_timeout().connect( sigc::mem_fun(*this, &SimDisplay::perform_step), 1000 );
}

bool SimDisplay::perform_step() {
  world->step();
  //on the last iteration this is called but on_expose_event is never reached
  get_window()->invalidate(true);
}

bool SimDisplay::on_expose_event(GdkEventExpose* event) {
  ...
}

Upvotes: 4

Views: 213

Answers (1)

unwind
unwind

Reputation: 400029

Your on_button_press_event() is missing a return statement; make sure all your handlers are returning the proper thing.

Upvotes: 1

Related Questions