From e48c2f6f96b974e2388783c98c0fa840609a66f6 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 6 Jan 2024 10:42:37 +0100 Subject: [PATCH] Don't fire callback inside locks, fixes #4516 Fixes #4516 --- widget/entry.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/widget/entry.go b/widget/entry.go index 1cbb707fcf..b68060a5cb 100644 --- a/widget/entry.go +++ b/widget/entry.go @@ -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() } @@ -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: