-
Notifications
You must be signed in to change notification settings - Fork 648
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
Problem with sync.WaitGroup and gtk? #30
Comments
Until further notice, I'm assuming this is a race condition I've created and that I just don't understand concurrency. |
Can you provide some sample code? (I do need to write documentation...) |
Sure, the code is here, and the problem is in main.go. main() starts listAccounts() as a goroutine, and when the user clicks the "Add" button to add a new account, listAccounts() starts editAccount(), passing it the address of an Account struct, then waits for it to finish changing the contents of the struct. My operating assumption is that I need to put a lock in here somewhere. |
For what it's worth, the race detector didn't find a race here. Here is the full error message I'm getting at the moment. |
I stripped the program down to its bare essentials: just a window with a button that starts a goroutine to open a second window. The program is still unstable, and crashes with X-related errors like this:
Or like this longer error. Any idea what might be the problem? |
And I figured out the problem: you can't open a second window in a goroutine. When I remove "go" from before the call to the function that opens the second window, the crashes disappear. |
Right, you'll need to do ui.Do() in that goroutine call as well. I really wish I didn't need to use that hacky workaround, but my previous attempts at using channels for events caused lots of problems :( |
Oh, I see -- ui.Do() is necessary anytime you call a goroutine that opens a window, not just in main()? I hadn't understood that from the documentation. Simply dropping "go" and calling it as a normal function seems to be working perfectly well for me so far. Thanks for your replies -- if I can help with documentation, let me know! |
Right, because your code is technically still running in ui.Do() =P The docs need work, yes; I did write a getting started guide on the wiki. |
I'm developing on Debian. I'm trying to use sync.WaitGroup in a program using the ui library, and it keeps dumping with this message:
It could be that I just don't understand what I'm doing yet (quite likely). But I also found this: http://stackoverflow.com/questions/18647475/threading-problems-with-gtk
The text was updated successfully, but these errors were encountered: