Skip to content

Commit

Permalink
add locking to hyperlink renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Feb 1, 2024
1 parent 77e922d commit 79a3065
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions widget/hyperlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,20 @@ func (r *hyperlinkRenderer) Destroy() {
}

func (r *hyperlinkRenderer) Layout(s fyne.Size) {
innerPad := theme.InnerPadding()
r.hl.propertyLock.RLock()
textSize := r.hl.textSize
w := r.hl.focusWidth()
xposFocus := r.hl.focusXPos()
r.hl.propertyLock.RUnlock()

innerPad := theme.InnerPadding()
xposUnderline := xposFocus + innerPad/2
lineCount := float32(len(r.hl.provider.rowBounds))

r.hl.provider.Resize(s)
lineCount := float32(len(r.hl.provider.rowBounds))
r.focus.Move(fyne.NewPos(xposFocus, innerPad/2))
r.focus.Resize(fyne.NewSize(w, r.hl.textSize.Height*lineCount+innerPad))
r.under.Move(fyne.NewPos(xposUnderline, r.hl.textSize.Height*lineCount+theme.Padding()*2))
r.focus.Resize(fyne.NewSize(w, textSize.Height*lineCount+innerPad))
r.under.Move(fyne.NewPos(xposUnderline, textSize.Height*lineCount+theme.Padding()*2))
r.under.Resize(fyne.NewSize(w-innerPad, 1))
}

Expand All @@ -310,6 +314,8 @@ func (r *hyperlinkRenderer) Objects() []fyne.CanvasObject {

func (r *hyperlinkRenderer) Refresh() {
r.hl.provider.Refresh()
r.hl.propertyLock.RLock()
defer r.hl.propertyLock.RUnlock()
r.focus.StrokeColor = theme.FocusColor()
r.focus.Hidden = !r.hl.focused
r.under.StrokeColor = theme.HyperlinkColor()
Expand Down

0 comments on commit 79a3065

Please sign in to comment.