-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
#4088
Changes from 13 commits
89d9511
43657e5
a3c774f
482dd36
ff93318
1f5d8ca
98b6ae4
e55e977
ace1a39
6093dfe
4c87831
4f00087
ccb94bf
4aafa01
15f4eba
19c89a3
4763eba
311e64f
420c689
ac73bbb
c66b390
360d864
13acfef
3e09f8f
a24be8c
abf356e
d2ba18e
cf3c4a0
a742a27
e5f328f
ed54385
0d32392
5ad0819
8af5e26
015cfdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,10 @@ 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 { | ||
self.add(clip_rect, Shape::Noop); | ||
} | ||
Comment on lines
+152
to
+154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be needed unless the user does something wrong, and even then this only works if it is exactly off-by-one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I experienced a panic occurring when self.0.len() was 0, and there is no problem if I use this. glow_integration and wgpu_integration must also be changed. I will add that part to this commit as well. How to reproduce panic:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fail to reproduce. In any case: try to find the root of the problem instead of adding defensive solutions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And use |
||
|
||
self.0[idx.0] = ClippedShape { clip_rect, shape }; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fall back to a texture atlas for the wrong pixels_per_point, which will likely look bad. The existing check is there to help users that write egui integration to find bugs in their code.
I'd rather figure out the root cause of the bug than mask it :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry, the texture atlas will be read for good pixel_per_point right away.
However, if you don't do this, a panic will occur before the texture atlas for a good pixel_per_point is read.
How to reproduce the panic is the same as the sequence shown above.
This also eliminates the root cause of the bug.
The root cause of another bug was fixed in #4128, so I didn't find it.