Use glib::timeout_add_local() instead of removed gtk::timeout_add()

This commit is contained in:
Sebastian Dröge 2020-08-27 09:49:03 +03:00
parent 3fef3a607f
commit 4cc6c0d19e
3 changed files with 3 additions and 3 deletions

View file

@ -84,7 +84,7 @@ fn create_ui(app: &gtk::Application) {
// the underlying pipeline, and display it in our gui. // the underlying pipeline, and display it in our gui.
// Since this closure is called by the mainloop thread, we are allowed // Since this closure is called by the mainloop thread, we are allowed
// to modify the gui widgets here. // to modify the gui widgets here.
let timeout_id = gtk::timeout_add(500, move || { let timeout_id = glib::timeout_add_local(500, move || {
// Here we temporarily retrieve a strong reference on the pipeline from the weak one // Here we temporarily retrieve a strong reference on the pipeline from the weak one
// we moved into this callback. // we moved into this callback.
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {

View file

@ -195,7 +195,7 @@ fn create_ui(app: &gtk::Application) {
// the underlying pipeline, and display it in our gui. // the underlying pipeline, and display it in our gui.
// Since this closure is called by the mainloop thread, we are allowed // Since this closure is called by the mainloop thread, we are allowed
// to modify the gui widgets here. // to modify the gui widgets here.
let timeout_id = gtk::timeout_add(500, move || { let timeout_id = glib::timeout_add_local(500, move || {
// Here we temporarily retrieve a strong reference on the pipeline from the weak one // Here we temporarily retrieve a strong reference on the pipeline from the weak one
// we moved into this callback. // we moved into this callback.
let pipeline = match pipeline_weak.upgrade() { let pipeline = match pipeline_weak.upgrade() {

View file

@ -167,7 +167,7 @@ mod tutorial5 {
let pipeline = playbin.clone(); let pipeline = playbin.clone();
let lslider = slider.clone(); let lslider = slider.clone();
// Update the UI (seekbar) every second // Update the UI (seekbar) every second
let timeout_id = gtk::timeout_add_seconds(1, move || { let timeout_id = glib::timeout_add_seconds_local(1, move || {
let pipeline = &pipeline; let pipeline = &pipeline;
let lslider = &lslider; let lslider = &lslider;