BillyDM / egui-baseview

A baseview backend for the egui Rust GUI library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The window close does not stop / drop the egui loop

alamminsalo opened this issue · comments

When reopening vst plugin window, the earlier draw loop continues to run, leading to multiple simultaneous ui-processes running.

Steps to reproduce: add times_opened usize to editor and pass incremented copy of it to window state. Then close and reopen window couple of times:

    fn close(&mut self) {
        self.is_open = false;
        if let Some(mut window_handle) = self.window_handle.take() {
            (window_handle.0).close();
        }
    }

    fn open(&mut self, parent: *mut ::std::ffi::c_void) -> bool {
        match self.is_open() {
            true => false,
            false => {
                // info!("Open editor");
                self.is_open = true;
                self.times_opened += 1;

                let settings = Settings {
                    ...
                };

                let window_handle = EguiWindow::open_parented(
                    &VstParent(parent),
                    settings,
                    (
                        self.times_opened,
                    ),
                    |_egui_ctx, _queue, _state| {},
                    |egui_ctx: &CtxRef, _, (times_opened)| {
                        info!("{}: draw", times_opened);
                        ui::draw_ui(egui_ctx); // ui draw func
                    },
                );

                self.window_handle = Some(WindowParent(window_handle));
                true
            }
        }

If opened 2 times, this prints continuously

1: draw
2: draw
1: draw
2: draw
...

Oh sorry, I'm really late to this one.

I've just made some changes that updates to using egui 0.19, so can you test if this is still an issue?

Hi, I experienced the same issue, this is on MacOS. I experimented by changing the dependency to this commit of baseview RustAudio/baseview@2c1b1a7 , which conveniently addresses the following issue: Fix window cleanup logic on macOS. I can confirm update stopped being called after I closed the window.