mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 21:14:31 -04:00
fix(tracker/gioui): text.Shaper should not be a global variable
text.Shaper is not thread safe, which caused crash when adding multiple VSTI plugins to a DAW project. This change fixes that crash. Further refactorings need to consider where that text.Shaper should actually reside.
This commit is contained in:
parent
3c85f1155c
commit
a38a0f4235
@ -20,6 +20,7 @@ type LabelStyle struct {
|
||||
Alignment layout.Direction
|
||||
Font font.Font
|
||||
FontSize unit.Sp
|
||||
Shaper *text.Shaper
|
||||
}
|
||||
|
||||
func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
@ -31,7 +32,7 @@ func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
dims := widget.Label{
|
||||
Alignment: text.Start,
|
||||
MaxLines: 1,
|
||||
}.Layout(gtx, textShaper, l.Font, l.FontSize, l.Text, op.CallOp{})
|
||||
}.Layout(gtx, l.Shaper, l.Font, l.FontSize, l.Text, op.CallOp{})
|
||||
return layout.Dimensions{
|
||||
Size: dims.Size.Add(image.Pt(2, 2)),
|
||||
Baseline: dims.Baseline,
|
||||
@ -42,11 +43,11 @@ func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
return widget.Label{
|
||||
Alignment: text.Start,
|
||||
MaxLines: 1,
|
||||
}.Layout(gtx, textShaper, l.Font, l.FontSize, l.Text, op.CallOp{})
|
||||
}.Layout(gtx, l.Shaper, l.Font, l.FontSize, l.Text, op.CallOp{})
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
func Label(str string, color color.NRGBA) layout.Widget {
|
||||
return LabelStyle{Text: str, Color: color, ShadeColor: black, Font: labelDefaultFont, FontSize: labelDefaultFontSize, Alignment: layout.W}.Layout
|
||||
func Label(str string, color color.NRGBA, shaper *text.Shaper) layout.Widget {
|
||||
return LabelStyle{Text: str, Color: color, ShadeColor: black, Font: labelDefaultFont, FontSize: labelDefaultFontSize, Alignment: layout.W, Shaper: shaper}.Layout
|
||||
}
|
||||
|
Reference in New Issue
Block a user