Skip to content

relm's event don't work when in a busy loop in the gtk GUI thread even if calling process_events #281

@emmanueltouzery

Description

@emmanueltouzery

see reproduction here:
https://github.com/emmanueltouzery/relm_process_events

the code adds 100k rows in a gtk treeview. It does so through a busy loop in the gtk GUI thread. BUT it doesn't freeze the GUI thread because it regularly calls:

                while gtk::events_pending() {
                    gtk::main_iteration();
                }

however that is not enough apparently to enable relm's event processing. It seems relm components' update() methods are called only after such a busy loop.
In this repro, I listen to double clicks on grid rows. When there is such a double click, I make a println!()... this works during the busy loop:

[src/main.rs:46] i = 65398
[src/main.rs:46] i = 65399
[src/main.rs:46] i = 65400
emitting relm event
[src/main.rs:46] i = 65401
[src/main.rs:46] i = 65402

however the update() itself, that should be called as a result of the stream().emit() being invoked, is not invoked until after the busy loop finishes:

    fn update(&mut self, event: Msg) {
        dbg!(event);
    }

[src/main.rs:46] i = 99997
[src/main.rs:46] i = 99998
[src/main.rs:46] i = 99999
emitting relm event
[src/main.rs:69] event = RowClicked
emitting relm event
[src/main.rs:69] event = RowClicked
emitting relm event
[src/main.rs:69] event = RowClicked

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions