Skip to content

Commit 4196697

Browse files
committed
Fixed panic, can't just unwrap the last element from batches to change the texture handle as we might not have created any batches yet.
1 parent 6891a81 commit 4196697

File tree

1 file changed

+4
-3
lines changed
  • crates/bevy_ui/src/render

1 file changed

+4
-3
lines changed

crates/bevy_ui/src/render/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,10 @@ pub fn prepare_uinodes(
781781
if replace(&mut batch_image_handle, extracted_uinode.image.id())
782782
== DEFAULT_IMAGE_HANDLE.id()
783783
{
784-
let existing_batch = batches.last_mut().unwrap();
785-
existing_batch.1.image_handle_id = extracted_uinode.image.id();
786-
Some(existing_batch)
784+
batches.last_mut().map(|existing_batch| {
785+
existing_batch.1.image_handle_id = batch_image_handle;
786+
existing_batch
787+
})
787788
} else {
788789
None
789790
}

0 commit comments

Comments
 (0)