Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

The window close does not stop / drop the egui loop #6

@alamminsalo

Description

@alamminsalo

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
...

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