15540 Make World::flush_commands private (#15553)
# Objective Fixes #15540 End-users risk using `World::flush_commands` instead of `World::flush`, which panics if any queued commands are `spawn`. Hiding `World::flush_commands` would help avoid calling a potentially panicky function, and helps alleviate end-user API confusion. ## Solution This PR updates the function visibility to crate-level, like `World::flush_entities`, hiding it from the end-user while still making it accessible for the tests that are currently set up. ## Testing The change was tested by executing the available tests for `bevy_ecs`. From what I've gathered, `World::flush_commands` is not used in any other bevy crate. If further testing is recommended, please inform me! --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
		
							parent
							
								
									73af2b7d29
								
							
						
					
					
						commit
						383c2e5bd7
					
				| @ -2474,19 +2474,13 @@ impl World { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// Flushes queued entities and calls [`World::flush_commands`].
 | ||||
|     #[inline] | ||||
|     pub fn flush(&mut self) { | ||||
|         self.flush_entities(); | ||||
|         self.flush_commands(); | ||||
|     } | ||||
| 
 | ||||
|     /// Applies any commands in the world's internal [`CommandQueue`].
 | ||||
|     /// This does not apply commands from any systems, only those stored in the world.
 | ||||
|     ///
 | ||||
|     /// # Panics
 | ||||
|     /// This will panic if any of the queued commands are [`spawn`](Commands::spawn).
 | ||||
|     /// If this is possible, you should instead use [`flush`](Self::flush).
 | ||||
|     pub fn flush_commands(&mut self) { | ||||
|     pub(crate) fn flush_commands(&mut self) { | ||||
|         // SAFETY: `self.command_queue` is only de-allocated in `World`'s `Drop`
 | ||||
|         if !unsafe { self.command_queue.is_empty() } { | ||||
|             // SAFETY: `self.command_queue` is only de-allocated in `World`'s `Drop`
 | ||||
| @ -2498,6 +2492,15 @@ impl World { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// Flushes queued entities and commands.
 | ||||
|     ///
 | ||||
|     /// Queued entities will be spawned, and then commands will be applied.
 | ||||
|     #[inline] | ||||
|     pub fn flush(&mut self) { | ||||
|         self.flush_entities(); | ||||
|         self.flush_commands(); | ||||
|     } | ||||
| 
 | ||||
|     /// Increments the world's current change tick and returns the old value.
 | ||||
|     ///
 | ||||
|     /// If you need to call this method, but do not have `&mut` access to the world,
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Andreas
						Andreas