Skip to content

Window despawns during Update schedule #13231

@gcx11

Description

@gcx11

Bevy version

5ee1b40

Relevant system information

Windows 11 + Vulkan

What you did

Close window with the close button when running following snippet

use bevy::app::{App, Startup, Update};
use bevy::DefaultPlugins;
use bevy::prelude::{Camera2dBundle, Commands, Query, Window};

fn setup(
    mut commands: Commands,
) {
    commands.spawn(Camera2dBundle::default());
}

fn check_window_status(
    window_query: Query<&Window>,
) {
    let window = window_query.get_single().unwrap();
    println!("Title: {}", window.title);
}

fn main() {
    let mut app = App::new();

    app.add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Update, check_window_status);

    app.run();
}

What went wrong

check_window_status triggers panic

thread 'Compute Task Pool (2)' panicked at src\main.rs:14:44:
called `Result::unwrap()` on an `Err` value: NoEntities("bevy_ecs::query::state::QueryState<&bevy_window::window::Window>")

Additional information

Previous commit (b8832dc) won't trigger panic

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions