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

Window freezes instead of closing #185

Open
sunjay opened this issue Jun 13, 2020 · 0 comments
Open

Window freezes instead of closing #185

sunjay opened this issue Jun 13, 2020 · 0 comments

Comments

@sunjay
Copy link
Owner

sunjay commented Jun 13, 2020

This is likely related at least in part to some of the issues in #183. In #173, we made it so that you could manage multiple turtle windows in multiple threads. We did that by no longer calling process::exit when a window is closed.

Unfortunately, if you create a window in a separate thread, closing the window doesn't actually cause the window to close. The following code reproduces the issue:

use std::thread;

use turtle::Turtle;

fn main() {
    turtle::start();

    thread::spawn(|| {
        let mut turtle = Turtle::new();

        for _ in 0..360 {
            // Move forward three steps
            turtle.forward(3.0);
            // Rotate to the right (clockwise) by 1 degree
            turtle.right(1.0);
            // panic!(); //TODO: Window should close
        }
    });

    thread::park();
}

Running this code and closing the window at any point should cause the window to disappear. Instead, the window remains open and freezes in place. The commented out panic!() should also cause the window to close, but it also results in the window just freezing instead.

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

No branches or pull requests

1 participant