Skip to content

TextWrapWord will cause crash in RichText #3498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
aynakeya opened this issue Dec 25, 2022 · 4 comments
Closed
2 tasks done

TextWrapWord will cause crash in RichText #3498

aynakeya opened this issue Dec 25, 2022 · 4 comments
Labels
unverified A bug that has been reported but not verified

Comments

@aynakeya
Copy link
Contributor

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

If a label in a Scroll container have its text starts with a space. and its Wrapping equals TextWrapWord.

eg

l :=widget.NewLabel(" AAAA")
l.Wrapping = fyne.TextWrapWord

Then program will crash at RichText.go with index out of range -1

image

How to reproduce

Run code in Example code will cause program to crash

Screenshots

image

Example code

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("Hello World")

	texts := make([]fyne.CanvasObject, 32)
	for i := 0; i < len(texts); i++ {
		l := widget.NewLabelWithStyle(
			" AAAA",
			fyne.TextAlignCenter, fyne.TextStyle{})
		l.Wrapping = fyne.TextWrapWord
		texts[i] = l
	}
	vbox := container.NewVBox(texts...)
	scroll := container.NewScroll(vbox)
	w.SetContent(scroll)
	w.Resize(fyne.NewSize(360, 540))
	w.ShowAndRun()
}

Fyne version

v2.2.4

Go compiler version

1.19

Operating system

Windows

Operating system version

Windows 10

Additional Information

No response

@aynakeya aynakeya added the unverified A bug that has been reported but not verified label Dec 25, 2022
@aynakeya
Copy link
Contributor Author

Maybe its the same problem as #3291

@andydotxyz
Copy link
Member

Please can you test against v2.3.0 which was released yesterday. Lots of text code was upgraded.

@aynakeya
Copy link
Contributor Author

Please can you test against v2.3.0 which was released yesterday. Lots of text code was upgraded.

Problem still exists in v2.3.0
image

@andydotxyz andydotxyz added this to the Fixes (v2.3.x) milestone Jan 17, 2023
@andydotxyz
Copy link
Member

Fixed on develop, thanks @alexballas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

2 participants