Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: panic when dragging window between monitors of different pixels_per_point #4868

Merged
merged 14 commits into from
Sep 17, 2024
12 changes: 7 additions & 5 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2418,12 +2418,14 @@ impl Context {

self.write(|ctx| {
let tessellation_options = ctx.memory.options.tessellation_options;
let texture_atlas = ctx
.fonts
.get(&pixels_per_point.into())
let texture_atlas = if let Some(fonts) = ctx.fonts.get(&pixels_per_point.into()) { fonts.texture_atlas() } else {
rustbasic marked this conversation as resolved.
Show resolved Hide resolved
#[cfg(feature = "log")]
log::warn!("No font size matching {pixels_per_point} pixels per point found.");
ctx.fonts.iter().next()
.expect("tessellate called with a different pixels_per_point than the font atlas was created with. \
You should use egui::FullOutput::pixels_per_point when tessellating.")
.texture_atlas();
You should use egui::FullOutput::pixels_per_point when tessellating.")
emilk marked this conversation as resolved.
Show resolved Hide resolved
.1.texture_atlas()
};
let (font_tex_size, prepared_discs) = {
let atlas = texture_atlas.lock();
(atlas.size(), atlas.prepared_discs())
Expand Down
6 changes: 6 additions & 0 deletions crates/egui/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ impl PaintList {
/// and then later setting it using `paint_list.set(idx, cr, frame);`.
#[inline(always)]
pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) {
if self.0.len() <= idx.0 {
#[cfg(feature = "log")]
log::warn!("Index {} is out of bounds for PaintList", idx.0);
self.add(clip_rect, Shape::Noop);
rustbasic marked this conversation as resolved.
Show resolved Hide resolved
}

self.0[idx.0] = ClippedShape { clip_rect, shape };
}

Expand Down
Loading