Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
emmanueltouzery opened this issue Mar 26, 2021 · 1 comment

Comments

@emmanueltouzery
Copy link
Contributor

emmanueltouzery commented Mar 26, 2021

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

@antoyo
Copy link
Owner

antoyo commented Aug 3, 2021

Sorry, I thought I had answered this question.
It seems like a bug indeed.
I don't have much time to debug this currently, but if you're willing, you could start by looking at whether those functions are called during the busy loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants