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 bit more code that could lead to a possible deadlock. #1968

Merged
merged 1 commit into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions crates/egui/src/containers/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,8 @@ impl SidePanel {
&& (resize_x - pointer.x).abs()
<= ui.style().interaction.resize_grab_radius_side;

if ui.input().pointer.any_pressed()
&& ui.input().pointer.any_down()
&& mouse_over_resize_line
{
let any_pressed = ui.input().pointer.any_pressed(); // avoid deadlocks
if any_pressed && ui.input().pointer.any_down() && mouse_over_resize_line {
ui.memory().set_dragged_id(resize_id);
}
is_resizing = ui.memory().is_being_dragged(resize_id);
Expand All @@ -229,8 +227,8 @@ impl SidePanel {
side.set_rect_width(&mut panel_rect, width);
}

let dragging_something_else =
ui.input().pointer.any_down() || ui.input().pointer.any_pressed();
let any_down = ui.input().pointer.any_down(); // avoid deadlocks
let dragging_something_else = any_down || ui.input().pointer.any_pressed();
resize_hover = mouse_over_resize_line && !dragging_something_else;

if resize_hover || is_resizing {
Expand Down Expand Up @@ -516,8 +514,8 @@ impl TopBottomPanel {
side.set_rect_height(&mut panel_rect, height);
}

let dragging_something_else =
ui.input().pointer.any_down() || ui.input().pointer.any_pressed();
let any_down = ui.input().pointer.any_down(); // avoid deadlocks
let dragging_something_else = any_down || ui.input().pointer.any_pressed();
resize_hover = mouse_over_resize_line && !dragging_something_else;

if resize_hover || is_resizing {
Expand Down
6 changes: 4 additions & 2 deletions crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,8 @@ fn window_interaction(
if window_interaction.is_none() {
if let Some(hover_window_interaction) = resize_hover(ctx, possible, area_layer_id, rect) {
hover_window_interaction.set_cursor(ctx);
if ctx.input().pointer.any_pressed() && ctx.input().pointer.primary_down() {
let any_pressed = ctx.input().pointer.any_pressed(); // avoid deadlocks
if any_pressed && ctx.input().pointer.primary_down() {
ctx.memory().interaction.drag_id = Some(id);
ctx.memory().interaction.drag_is_window = true;
window_interaction = Some(hover_window_interaction);
Expand Down Expand Up @@ -612,7 +613,8 @@ fn resize_hover(
) -> Option<WindowInteraction> {
let pointer = ctx.input().pointer.interact_pos()?;

if ctx.input().pointer.any_down() && !ctx.input().pointer.any_pressed() {
let any_down = ctx.input().pointer.any_down(); // avoid deadlocks
if any_down && !ctx.input().pointer.any_pressed() {
return None; // already dragging (something)
}

Expand Down