From ddaec62bb952a25ec1a141affe922be9314af55d Mon Sep 17 00:00:00 2001 From: devil-ira Date: Mon, 5 Sep 2022 15:27:42 +0200 Subject: [PATCH 1/5] more like, footgone, amirite --- crates/bevy_window/src/lib.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index 005675f2ae26f..3db0165979a66 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -7,6 +7,7 @@ mod window; mod windows; pub use crate::raw_window_handle::*; +use bevy_utils::tracing::warn; pub use cursor::*; pub use event::*; pub use system::*; @@ -25,7 +26,7 @@ use bevy_app::prelude::*; use bevy_ecs::{ event::Events, schedule::{ParallelSystemDescriptorCoercion, SystemLabel}, - system::Resource, + system::{Local, Res, Resource}, }; /// The configuration information for the [`WindowPlugin`]. @@ -99,8 +100,7 @@ impl Plugin for WindowPlugin { if settings.add_primary_window { let window_descriptor = app .world - .get_resource::() - .cloned() + .remove_resource::() .unwrap_or_default(); let mut create_window_event = app.world.resource_mut::>(); create_window_event.send(CreateWindow { @@ -118,6 +118,16 @@ impl Plugin for WindowPlugin { if settings.close_when_requested { app.add_system(close_when_requested); } + + #[cfg(debug_assertions)] + { + app.add_system(|wd: Option>, mut once: Local| { + if !*once && wd.is_some() { + warn!("The WindowDescriptor resource must be inserted before the WindowPlugin is added. Make sure to insert WindowDescriptor before adding the DefaultPlugins."); + *once = true; + } + }); + } } } From 09504f8c8e9622dd60193f7543abdb360322a438 Mon Sep 17 00:00:00 2001 From: devil-ira Date: Mon, 5 Sep 2022 15:41:38 +0200 Subject: [PATCH 2/5] A change in strategy. --- crates/bevy_window/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index 3db0165979a66..38fbbf07f6d12 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -26,7 +26,7 @@ use bevy_app::prelude::*; use bevy_ecs::{ event::Events, schedule::{ParallelSystemDescriptorCoercion, SystemLabel}, - system::{Local, Res, Resource}, + system::{Res, Resource}, }; /// The configuration information for the [`WindowPlugin`]. @@ -121,10 +121,11 @@ impl Plugin for WindowPlugin { #[cfg(debug_assertions)] { - app.add_system(|wd: Option>, mut once: Local| { - if !*once && wd.is_some() { - warn!("The WindowDescriptor resource must be inserted before the WindowPlugin is added. Make sure to insert WindowDescriptor before adding the DefaultPlugins."); - *once = true; + app.add_system(|wd: Option>| { + if let Some(wd) = wd { + if wd.is_added() { + warn!("The WindowDescriptor resource must be inserted before the WindowPlugin is added. Make sure to insert WindowDescriptor before adding the DefaultPlugins."); + } } }); } From 6476dcd724e4983146836a155113debaf09ba912 Mon Sep 17 00:00:00 2001 From: devil-ira Date: Mon, 5 Sep 2022 15:48:58 +0200 Subject: [PATCH 3/5] Remove brackets. --- crates/bevy_window/src/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index 38fbbf07f6d12..2c58eec1c795c 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -120,15 +120,13 @@ impl Plugin for WindowPlugin { } #[cfg(debug_assertions)] - { - app.add_system(|wd: Option>| { - if let Some(wd) = wd { - if wd.is_added() { - warn!("The WindowDescriptor resource must be inserted before the WindowPlugin is added. Make sure to insert WindowDescriptor before adding the DefaultPlugins."); - } + app.add_system(|wd: Option>| { + if let Some(wd) = wd { + if wd.is_added() { + warn!("The WindowDescriptor resource must be inserted before the WindowPlugin is added. Make sure to insert WindowDescriptor before adding the DefaultPlugins."); } - }); - } + } + }); } } From 9f4611aaa8afc2833fba4df55b5f841ebb493c10 Mon Sep 17 00:00:00 2001 From: ira Date: Mon, 5 Sep 2022 15:55:10 +0200 Subject: [PATCH 4/5] split message Co-authored-by: Nicola Papale --- crates/bevy_window/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index 2c58eec1c795c..5781dd089977d 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -123,7 +123,10 @@ impl Plugin for WindowPlugin { app.add_system(|wd: Option>| { if let Some(wd) = wd { if wd.is_added() { - warn!("The WindowDescriptor resource must be inserted before the WindowPlugin is added. Make sure to insert WindowDescriptor before adding the DefaultPlugins."); + warn!( + "The WindowDescriptor resource must be inserted before the WindowPlugin is added. \ + Make sure to insert WindowDescriptor before adding the DefaultPlugins.", + ); } } }); From bf2ea3149e660530b394533f369dbc6704d97d12 Mon Sep 17 00:00:00 2001 From: ira Date: Tue, 6 Sep 2022 19:07:19 +0200 Subject: [PATCH 5/5] Update crates/bevy_window/src/lib.rs Co-authored-by: Afonso Lage --- crates/bevy_window/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_window/src/lib.rs b/crates/bevy_window/src/lib.rs index 5781dd089977d..be52e19a11255 100644 --- a/crates/bevy_window/src/lib.rs +++ b/crates/bevy_window/src/lib.rs @@ -125,7 +125,7 @@ impl Plugin for WindowPlugin { if wd.is_added() { warn!( "The WindowDescriptor resource must be inserted before the WindowPlugin is added. \ - Make sure to insert WindowDescriptor before adding the DefaultPlugins.", + Make sure to insert WindowDescriptor before adding the DefaultPlugins or the WindowPlugin.", ); } }