Skip to content

Commit

Permalink
bevyengine#4241: fix PR feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Dec 21, 2022
1 parent 87ea20c commit fd3ac47
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct App {
plugin_name_added: HashSet<String>,
/// A private marker to prevent incorrect calls to `App::run()` from `Plugin::build()`
/// <https://github.com/bevyengine/bevy/issues/4231>
is_from_plugin_build: bool,
is_building_plugin: bool,
}

impl Debug for App {
Expand Down Expand Up @@ -139,7 +139,7 @@ impl App {
sub_apps: HashMap::default(),
plugin_registry: Vec::default(),
plugin_name_added: Default::default(),
is_from_plugin_build: false,
is_building_plugin: false,
}
}

Expand Down Expand Up @@ -170,8 +170,8 @@ impl App {
let _bevy_app_run_span = info_span!("bevy_app").entered();

let mut app = std::mem::replace(self, App::empty());
if app.is_from_plugin_build {
panic!("App::Run() is called from a Plugin::Build(), which might result in other initialization code not run.");
if app.is_building_plugin {
panic!("App::run() was called from within Plugin::Build(), which is not allowed.");
}
let runner = std::mem::replace(&mut app.runner, Box::new(run_once));
(runner)(app);
Expand Down Expand Up @@ -865,9 +865,9 @@ impl App {
plugin_name: plugin.name().to_string(),
})?;
}
self.is_from_plugin_build = true;
self.is_building_plugin = true;
plugin.build(self);
self.is_from_plugin_build = false;
self.is_building_plugin = true;
self.plugin_registry.push(plugin);
Ok(self)
}
Expand Down

0 comments on commit fd3ac47

Please sign in to comment.