mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 21:00:03 -04:00
Fix crash when closing end opening a viewport really fast
The problem was that a lot of stuff was tring to acces the viewport after was destroyed! Now the viewport data from Memory will only be cleared when a new frame beagins!
This commit is contained in:
@@ -226,6 +226,7 @@ impl ContextImpl {
|
||||
self.memory.begin_frame(
|
||||
self.input.get(&viewport_id).unwrap_or(&Default::default()),
|
||||
&new_raw_input,
|
||||
&ViewportIdSet::from_iter(self.viewports.keys().cloned().chain([ViewportId::ROOT])),
|
||||
);
|
||||
|
||||
let input = self
|
||||
@@ -1476,7 +1477,6 @@ impl Context {
|
||||
let textures_delta = self.write(|ctx| {
|
||||
ctx.memory.end_frame(
|
||||
&ctx.input[&ctx.viewport_id()],
|
||||
&viewports,
|
||||
&ctx.frame_state
|
||||
.entry(ctx.viewport_id())
|
||||
.or_default()
|
||||
|
||||
@@ -550,9 +550,16 @@ impl Memory {
|
||||
&mut self,
|
||||
prev_input: &crate::input_state::InputState,
|
||||
new_input: &crate::data::input::RawInput,
|
||||
viewports: &ViewportIdSet,
|
||||
) {
|
||||
crate::profile_function!();
|
||||
|
||||
// Cleanup
|
||||
self.interactions.retain(|id, _| viewports.contains(id));
|
||||
self.areas.retain(|id, _| viewports.contains(id));
|
||||
self.window_interactions
|
||||
.retain(|id, _| viewports.contains(id));
|
||||
|
||||
self.viewport_id = new_input.viewport.id_pair.this;
|
||||
self.interactions
|
||||
.entry(self.viewport_id)
|
||||
@@ -565,20 +572,11 @@ impl Memory {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn end_frame(
|
||||
&mut self,
|
||||
input: &InputState,
|
||||
viewports: &ViewportIdSet,
|
||||
used_ids: &IdMap<Rect>,
|
||||
) {
|
||||
pub(crate) fn end_frame(&mut self, input: &InputState, used_ids: &IdMap<Rect>) {
|
||||
self.caches.update();
|
||||
self.areas_mut().end_frame();
|
||||
self.interaction_mut().focus.end_frame(used_ids);
|
||||
self.drag_value.end_frame(input);
|
||||
self.interactions.retain(|id, _| viewports.contains(id));
|
||||
self.areas.retain(|id, _| viewports.contains(id));
|
||||
self.window_interactions
|
||||
.retain(|id, _| viewports.contains(id));
|
||||
}
|
||||
|
||||
pub(crate) fn set_viewport_id(&mut self, viewport_id: ViewportId) {
|
||||
|
||||
Reference in New Issue
Block a user