Check if signal is processed for GObject

34 views Asked by At

[Gtk4] In some thread, I was change label of widget and next call window destroy function. Problem was, X11 backend raise BadAccess error on painting function. I need to check if signal for widget/gobject is processed and if so, delay window destroy routine.

  1. There is no function to check this. In Gtk3 I can call gtk_get_event_widget(gtk_get_current_event()), but Gtk4 is more complicated and need to use event controller. How to correctly use it to detect if widget signal is processed?

  2. Is there way to use any callbacks called before signal was processed and after with widget given as parameter?

Thanks.

1

There are 1 answers

0
ebassi On

The question is the wrong approach. The right question would be: "how do I update the UI from inside the thread in a way that is not straight calling GTK API, which is not possible because only the thread that is spinning the main loop can call GTK API?"

The answer to the right question is: schedule a function call from the thread into the main loop, using g_main_context_invoke(); construct a data structure that holds all the data that should be used by the UI thread, and pass it to the invoked function.