Skip to content

Commit

Permalink
Fix dead-lock in TextEdit on touch-screens (#1118)
Browse files Browse the repository at this point in the history
Introduced in #1035

Fixes #1116
  • Loading branch information
emilk committed Jan 15, 2022
1 parent b2c8cd0 commit ad54187
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w

### Changed 🔧
* ⚠️ `Context::input` and `Ui::input` now locks a mutex. This can lead to a dead-lock is used in an `if let` binding!
* `if let Some(pos) = ui.input().pointer.latest_pos()` and similar must now be rewritten on two lines, or with added `{}` around the righ-hand-side.
* `if let Some(pos) = ui.input().pointer.latest_pos()` and similar must now be rewritten on two lines.
* Search for this problem in your code using the regex `if let .*input`.
* Renamed `CtxRef` to `Context` ([#1050](https://github.com/emilk/egui/pull/1050)).
* `Context` can now be cloned and stored between frames ([#1050](https://github.com/emilk/egui/pull/1050)).
Expand Down
3 changes: 2 additions & 1 deletion egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ impl<'t> TextEdit<'t> {
// dragging select text, or scroll the enclosing `ScrollArea` (if any)?
// Since currently copying selected text in not supported on `egui_web`,
// we prioritize touch-scrolling:
let allow_drag_to_select = !ui.input().any_touches() || ui.memory().has_focus(id);
let any_touches = ui.input().any_touches(); // separate line to avoid double-locking the same mutex
let allow_drag_to_select = !any_touches || ui.memory().has_focus(id);

let sense = if interactive {
if allow_drag_to_select {
Expand Down

0 comments on commit ad54187

Please sign in to comment.