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

Calling SetContent from Window OnDropped can freeze application #4624

Closed
2 tasks done
codesoap opened this issue Feb 10, 2024 · 8 comments
Closed
2 tasks done

Calling SetContent from Window OnDropped can freeze application #4624

codesoap opened this issue Feb 10, 2024 · 8 comments
Labels
unverified A bug that has been reported but not verified
Milestone

Comments

@codesoap
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

I have added a SetOnDropped handler to the main window of my application. If the handler just does something trivial, like printing to stdout, everything works as expected. If, however, the handler calls SetContent on the window, the SetContent is run and then the application freezes forever.

How to reproduce

I can create the problem by running the test program and dropping a file into the application window.

Screenshots

No response

Example code

package main

import "fyne.io/fyne/v2"
import "fyne.io/fyne/v2/app"
import "fyne.io/fyne/v2/widget"

func main() {
	a := app.New()
	w := a.NewWindow("test")
	w.SetOnDropped(func(pos fyne.Position, uris []fyne.URI) {
		w.SetContent(widget.NewLabel("File dropped"))
	})
	w.ShowAndRun()
}

Fyne version

2.4.3

Go compiler version

1.22.0

Operating system and version

MX Linux, I believe version 21; it's basically Debian

Additional Information

No response

@codesoap codesoap added the unverified A bug that has been reported but not verified label Feb 10, 2024
@codesoap
Copy link
Contributor Author

While searching for existing code that uses SetOnDropped, I found this: https://github.com/metal3d/fyne-streamer/blob/8800be35603ad89a6599e6a09152a988655e828a/examples/blender-peertube/main.go#L111

It looks like someone else already found the bug and also found a workaround. This works:

package main

import "fyne.io/fyne/v2"
import "fyne.io/fyne/v2/app"
import "fyne.io/fyne/v2/widget"

func main() {
	a := app.New()
	w := a.NewWindow("test")
	w.SetOnDropped(func(pos fyne.Position, uris []fyne.URI) {
		go func() { w.SetContent(widget.NewLabel("File dropped")) }()
	})
	w.ShowAndRun()
}

@andydotxyz andydotxyz changed the title Window.SetOnDropped can crash application Window.SetOnDropped can freeze application Feb 11, 2024
@andydotxyz
Copy link
Member

Updated title to be freeze not crash as they are quite different

@andydotxyz andydotxyz changed the title Window.SetOnDropped can freeze application Calling SetContent from Window OnDropped can freeze application Feb 11, 2024
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Feb 11, 2024
@andydotxyz
Copy link
Member

Fixed on Develop branch, but it probably missed v2.4.4 - if we do 2.4.5 before 2.5.0 then this should be in it

@andydotxyz andydotxyz added this to the v2.4.5 milestone Feb 11, 2024
@codesoap
Copy link
Contributor Author

Awesome, thanks for the lightning fast fix, @andydotxyz ! I'll try to test it with the development branch, when I find some time.

@codesoap
Copy link
Contributor Author

I've now tested on the develop branch and don't see the problem anymore. Thanks again!

@codesoap
Copy link
Contributor Author

Milestone v2.4.5 had been set for this issue, but the fix has not been released with v2.4.5. Was this ticket missed when preparing the release or was this a conscious choice?

andydotxyz added a commit that referenced this issue Apr 17, 2024
@andydotxyz andydotxyz modified the milestones: v2.4.5, v2.4.6 Apr 17, 2024
@andydotxyz
Copy link
Member

You're right this was missed somehow.
It is now picked to the release branch so that whatever release comes next it will certainly be included.
Sorry about that.

@codesoap
Copy link
Contributor Author

No worries and thanks for the quick action ❤️

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