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

Tracing Error When Window Closed #3915

Closed
Shadowcat650 opened this issue Sep 11, 2024 · 2 comments
Closed

Tracing Error When Window Closed #3915

Shadowcat650 opened this issue Sep 11, 2024 · 2 comments
Labels
B - bug Dang, that shouldn't have happened DS - macos

Comments

@Shadowcat650
Copy link

Description

When the I exit the event loop, a tracing error is given.

Code that caused the error:

use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::window::{Window, WindowAttributes, WindowId};

fn main() {
    tracing_subscriber::fmt::init();

    let mut app = App {
        window: None
    };

    let event_loop = EventLoop::new().unwrap();
    event_loop.run_app(&mut app).unwrap();
}

struct App {
    window: Option<Window>
}

impl ApplicationHandler for App {
    fn resumed(&mut self, event_loop: &ActiveEventLoop) {
        self.window = Some(event_loop.create_window(WindowAttributes::default()).unwrap());
    }

    fn window_event(&mut self, event_loop: &ActiveEventLoop, _window_id: WindowId, event: WindowEvent) {
        match event {
            WindowEvent::CloseRequested => event_loop.exit(),
            _ => ()
        }
    }
}

The error:

2024-09-11T22:44:09.138281Z ERROR winit::platform_impl::macos::event_handler: tried to run event handler, but no handler was set

macOS version

ProductName:		macOS
ProductVersion:		14.6.1
BuildVersion:		23G93

Winit version

0.30.5

@Shadowcat650 Shadowcat650 added B - bug Dang, that shouldn't have happened DS - macos labels Sep 11, 2024
@madsmtm
Copy link
Member

madsmtm commented Sep 11, 2024

I suspect this is due to the window being dropped after the application has exited, and I think it will be fixed by #3895.

In the meantime, try doing self.window = None inside CloseRequested?

@Shadowcat650
Copy link
Author

In the meantime, try doing self.window = None inside CloseRequested?

Thanks, that fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened DS - macos
Development

No branches or pull requests

2 participants