Skip to content
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

Various interface conversion panics when selecting text in a widget.Entry #1983

Closed
csmith opened this issue Feb 20, 2021 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@csmith
Copy link

csmith commented Feb 20, 2021

Describe the bug:

Occasionally when selecting text in a multi-line widget.Entry, one of these panics occur:

panic: interface conversion: fyne.CanvasObject is *widget.textProvider, not *canvas.Rectangle

goroutine 12 [running]:
fyne.io/fyne/v2/widget.(*entryContentRenderer).Refresh(0xc000067260)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1333 +0x493
fyne.io/fyne/v2/widget.(*entryRenderer).Refresh(0xc000024680)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1193 +0x35c
fyne.io/fyne/v2/widget.(*BaseWidget).Refresh(0xc0002be480)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/widget.go:139 +0x5c
fyne.io/fyne/v2/widget.(*BaseWidget).setFieldsAndRefresh(0xc0002be480, 0xc00004cef0)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/widget.go:165 +0x7e
fyne.io/fyne/v2/widget.(*Entry).updateMousePointer(0xc0002be480, 0xc000209340, 0xc000546400)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1036 +0x97
fyne.io/fyne/v2/widget.(*Entry).Dragged(0xc0002be480, 0xc000209340)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:245 +0x45
fyne.io/fyne/v2/widget.(*entryContent).Dragged(0xc0000704b0, 0xc000209340)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1253 +0x39
fyne.io/fyne/v2/internal/driver/glfw.(*window).mouseMoved.func4()
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/internal/driver/glfw/window.go:667 +0x38
fyne.io/fyne/v2/internal/driver/glfw.(*window).runEventQueue(0xc00014a1c0)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/internal/driver/glfw/window.go:1242 +0x7a
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/internal/driver/glfw/window.go:1266 +0x10d

and:

panic: interface conversion: fyne.CanvasObject is *widget.textProvider, not *canvas.Rectangle

goroutine 25 [running]:
fyne.io/fyne/v2/widget.(*entryContentRenderer).Refresh(0xc0000b7200)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1333 +0x493
fyne.io/fyne/v2/widget.(*entryRenderer).Refresh(0xc0000cc600)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1193 +0x35c
fyne.io/fyne/v2/widget.(*BaseWidget).Refresh(0xc000083200)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/widget.go:139 +0x5c
fyne.io/fyne/v2/widget.(*BaseWidget).setFieldsAndRefresh(0xc000083200, 0xc00004cef0)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/widget.go:165 +0x7e
fyne.io/fyne/v2/widget.(*Entry).updateMousePointer(0xc000083200, 0xc0004e0c60, 0xc000620300)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1036 +0x97
fyne.io/fyne/v2/widget.(*Entry).Dragged(0xc000083200, 0xc0004e0c60)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:245 +0x45
fyne.io/fyne/v2/widget.(*entryContent).Dragged(0xc0000b8460, 0xc0004e0c60)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/widget/entry.go:1253 +0x39
fyne.io/fyne/v2/internal/driver/glfw.(*window).mouseMoved.func4()
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/internal/driver/glfw/window.go:667 +0x38
fyne.io/fyne/v2/internal/driver/glfw.(*window).runEventQueue(0xc0000fe1c0)
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/internal/driver/glfw/window.go:1242 +0x7a
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1
        .../go/pkg/mod/fyne.io/fyne/v2@v2.0.0/internal/driver/glfw/window.go:1266 +0x10d

To Reproduce:

This is about a 90% reproduction for me:

  1. Create a widget.Entry configured with Wrapping = fyne.TextWrapWord and MultiLine = true
  2. Add sufficient text that the widget scrolls
  3. Mouse down to start selecting the first line of text and drag the cursor down to select the rest, forcing the widget to scroll
  4. After selecting down to the bottom, move the cursor back up to start deselecting some of the bottom text

After step 3 the selection seems to get a bit laggy, or ignores the cursor for a bit, and then when it starts again in step 4 fyne panics.

Screenshots:

Peek 2021-02-20 00-08

Example code:

package main

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

var (
	input = widget.NewEntry()
	output = widget.NewEntry()
)

func main() {
	seeker := app.New()
	window := seeker.NewWindow("Seeker")
	window.Resize(fyne.Size{Width: 800, Height: 300})
	window.SetContent(container.NewGridWithColumns(2, leftColumn()))
	input.Wrapping = fyne.TextWrapWord
	input.MultiLine = true
	output.MultiLine = true
	output.Disable()

	input.SetText("Hello,\nthis\nis\na\ntest\nFoo\nbar\nbaz\nline\nline\nline")

	window.Show()
	seeker.Run()
}

func leftColumn() *fyne.Container {
	return container.NewGridWithColumns(1,
		container.NewBorder(
			widget.NewLabel("Input:"),
			nil,
			nil,
			nil,
			input,
		),
		container.NewBorder(
			widget.NewLabel("Output:"),
			nil,
			nil,
			nil,
			container.NewMax(output),
		),
	)
}

Device (please complete the following information):

  • OS: Linux
  • Version: Arch (up-to-date as of 2020-02-20)
  • Go version: 1.15.8
  • Fyne version: fyne.io/fyne/v2 v2.0.0 h1:TfsS3bNq5663BpXsoz1OfzyjcaMqqOf9usI8ZKkw4IE=
@csmith csmith added the bug Something isn't working label Feb 20, 2021
@csmith
Copy link
Author

csmith commented Feb 20, 2021

Sample content of selections when it panics:

image

But I can't see anywhere that actually adds a widget.textProvider to selections...

@fpabl0
Copy link
Member

fpabl0 commented Feb 20, 2021

That's a good catch. Thanks for reporting this.

Jacalz added a commit that referenced this issue Feb 21, 2021
Do not append entryContentRenderer's objects in the selection slice, fixes #1983
@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2021

Fixed on the develop branch as of 78b4eaf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants