Fix deadlock when using show_blocking_widget (#2753)
Calling the layer painter from inside a write() call causes a deadlock on the Context. This change stores the necessary data (the two overlapping Rects) in the write() call but uses them outside. Closes #2752
This commit is contained in:
parent
7215fdfb7c
commit
f85a25307d
|
|
@ -565,6 +565,7 @@ impl Context {
|
|||
Stroke::new(1.0, Color32::YELLOW.additive().linear_multiply(0.05)),
|
||||
);
|
||||
}
|
||||
let mut show_blocking_widget = None;
|
||||
|
||||
self.write(|ctx| {
|
||||
ctx.layer_rects_this_frame
|
||||
|
|
@ -585,16 +586,9 @@ impl Context {
|
|||
// so we aren't hovered.
|
||||
|
||||
if ctx.memory.options.style.debug.show_blocking_widget {
|
||||
Self::layer_painter(self, LayerId::debug()).debug_rect(
|
||||
interact_rect,
|
||||
Color32::GREEN,
|
||||
"Covered",
|
||||
);
|
||||
Self::layer_painter(self, LayerId::debug()).debug_rect(
|
||||
prev_rect,
|
||||
Color32::LIGHT_BLUE,
|
||||
"On top",
|
||||
);
|
||||
// Store the rects to use them outside the write() call to
|
||||
// avoid deadlock
|
||||
show_blocking_widget = Some((interact_rect, prev_rect));
|
||||
}
|
||||
|
||||
hovered = false;
|
||||
|
|
@ -605,6 +599,19 @@ impl Context {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
if let Some((interact_rect, prev_rect)) = show_blocking_widget {
|
||||
Self::layer_painter(self, LayerId::debug()).debug_rect(
|
||||
interact_rect,
|
||||
Color32::GREEN,
|
||||
"Covered",
|
||||
);
|
||||
Self::layer_painter(self, LayerId::debug()).debug_rect(
|
||||
prev_rect,
|
||||
Color32::LIGHT_BLUE,
|
||||
"On top",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self.interact_with_hovered(layer_id, id, rect, sense, enabled, hovered)
|
||||
|
|
|
|||
Loading…
Reference in New Issue