fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design

Home Page:https://fyne.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple select popups during background operations (crash)

stridebn opened this issue · comments

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

When clicking multiple times on a select object while the program is performing background tasks, many Fyne reads each click and generates multiple popups below the select. This causes the program to crash.

How to reproduce

During any background operation where the window is unresponsive, click multiple times on any select. Once the window is responsive, click on the dropdown menus to select items. Multiple popups will have generated, and a click on any but the top will crash the program.

Screenshots

No response

Example code

The following can be put in an application to demonstrate the issue.

    selectOptions := []string{"Option 1", "Option 2"}
    testSelect := widget.NewSelect(selectOptions, func(selected string) {
        fmt.Println("selected: ", selected)
    })
    testSelect.PlaceHolder = "Click me multiple times after clicking the button"
    waitButton := widget.NewButton("Click me!", func() {
        start := time.Now()
        // Loop until the specified duration has passed
        for time.Since(start) < (5 * time.Second) {
            // This is the busy wait part, where the loop continuously checks the time
        }
    })

Fyne version

2.4.4

Go compiler version

1.19.2

Operating system and version

Mac 12.7.1

Additional Information

No response

During any background operation where the window is unresponsive

The window should never be unresponsive - this points towards a potential issue outside what is reported above.

Multiple popups will have generated, and a click on any but the top will crash the program.

Can you please provide the crash log that is occurring in this situation?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x10051ee99]

goroutine 41 [running]:
fyne.io/fyne/v2/widget.(*PopUpMenu).Hide(0x0)
/Users/brennans/go/src/fyne/widget/popup_menu.go:68 +0x19
fyne.io/fyne/v2/widget.(*Select).showPopUp.func2()
/Users/brennans/go/src/fyne/widget/select.go:256 +0x29
fyne.io/fyne/v2/widget.(*Menu).Dismiss(0xc003f56480?)
/Users/brennans/go/src/fyne/widget/menu.go:194 +0xaf
fyne.io/fyne/v2/widget.(*menuItem).trigger(0xc00429ca80)
/Users/brennans/go/src/fyne/widget/menu_item.go:205 +0x25
fyne.io/fyne/v2/widget.(*menuItem).Tapped(0xc001829fb0?, 0xc000038401?)
/Users/brennans/go/src/fyne/widget/menu_item.go:153 +0x58
fyne.io/fyne/v2/internal/driver/glfw.(*window).mouseClickedHandleTapDoubleTap.func1()
/Users/brennans/go/src/fyne/internal/driver/glfw/window.go:650 +0x26
fyne.io/fyne/v2/internal/driver/common.(*Window).RunEventQueue(0x0?)
/Users/brennans/go/src/fyne/internal/driver/common/window.go:35 +0x3e
created by fyne.io/fyne/v2/internal/driver/glfw.(*gLDriver).createWindow.func1
/Users/brennans/go/src/fyne/internal/driver/glfw/window.go:960 +0x136
exit status 2

This is landed on develop and the release branch, it will be on v2.4.5