Skip to content

Commit

Permalink
Don't fire callback inside locks, fixes fyne-io#4516
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Jan 6, 2024
1 parent c264577 commit e48c2f6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions widget/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,12 @@ func (e *Entry) cutToClipboard(clipboard fyne.Clipboard) {

e.copyToClipboard(clipboard)
e.setFieldsAndRefresh(e.eraseSelection)
e.propertyLock.Lock()
e.propertyLock.RLock()
content := e.Text
e.propertyLock.RUnlock()
if e.OnChanged != nil {
e.OnChanged(e.Text)
e.OnChanged(content)
}
e.propertyLock.Unlock()
e.Validate()
}

Expand Down Expand Up @@ -1092,11 +1093,13 @@ func (e *Entry) selectingKeyHandler(key *fyne.KeyEvent) bool {
case fyne.KeyBackspace, fyne.KeyDelete:
// clears the selection -- return handled
e.setFieldsAndRefresh(e.eraseSelection)
e.propertyLock.Lock()

e.propertyLock.RLock()
content := e.Text
e.propertyLock.RUnlock()
if e.OnChanged != nil {
e.OnChanged(e.Text)
e.OnChanged(content)
}
e.propertyLock.Unlock()
e.Validate()
return true
case fyne.KeyReturn, fyne.KeyEnter:
Expand Down

0 comments on commit e48c2f6

Please sign in to comment.