Skip to content

Commit 237aa2c

Browse files
committed
Fix dead-lock in TextEdit on touch-screens
Introduced in #1035 Fixes #1116
1 parent b2c8cd0 commit 237aa2c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
1313

1414
### Changed 🔧
1515
* ⚠️ `Context::input` and `Ui::input` now locks a mutex. This can lead to a dead-lock is used in an `if let` binding!
16-
* `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.
16+
* `if let Some(pos) = ui.input().pointer.latest_pos()` and similar must now be rewritten on two lines.
1717
* Search for this problem in your code using the regex `if let .*input`.
1818
* Renamed `CtxRef` to `Context` ([#1050](https://github.com/emilk/egui/pull/1050)).
1919
* `Context` can now be cloned and stored between frames ([#1050](https://github.com/emilk/egui/pull/1050)).

egui/src/widgets/text_edit/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ impl<'t> TextEdit<'t> {
390390
// dragging select text, or scroll the enclosing `ScrollArea` (if any)?
391391
// Since currently copying selected text in not supported on `egui_web`,
392392
// we prioritize touch-scrolling:
393-
let allow_drag_to_select = !ui.input().any_touches() || ui.memory().has_focus(id);
393+
let any_touches = ui.input().any_touches(); // separate line to avoid double-locking the same mutex
394+
let allow_drag_to_select = !any_touches || ui.memory().has_focus(id);
394395

395396
let sense = if interactive {
396397
if allow_drag_to_select {

0 commit comments

Comments
 (0)