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

walk.NewMainWindow hangs in win.SendMessage #337

Closed
tmm1 opened this issue Oct 31, 2017 · 2 comments
Closed

walk.NewMainWindow hangs in win.SendMessage #337

tmm1 opened this issue Oct 31, 2017 · 2 comments

Comments

@tmm1
Copy link
Contributor

tmm1 commented Oct 31, 2017

I integrated the notifyicon example into a complex app with many goroutines, and walk.NewMainWindow never returns the rest of my code (including walk.NewNotifyIcon) never executes:

goroutine 1 [syscall, locked to thread]:
syscall.Syscall6(0x7fff83c90ef0, 0x4, 0x60344, 0x432, 0x0, 0xc0423a1650, 0x0, 0x0, 0x0, 0x75, ...)
	src/runtime/syscall_windows.go:174 +0x69
github.com/lxn/win.SendMessage(0x60344, 0x432, 0x0, 0xc0423a1650, 0xc4a1e4)
	src/github.com/lxn/win/user32.go:2641 +0x7b
github.com/lxn/walk.(*WindowBase).SendMessage(0xc04206b440, 0x432, 0x0, 0xc0423a1650, 0x458830)
	src/github.com/lxn/walk/window.go:601 +0x52
github.com/lxn/walk.(*ToolTip).addTool(0xc04206b440, 0x1400900, 0xc0421b6840, 0x0, 0x350a0a8c, 0x1)
	src/github.com/lxn/walk/tooltip.go:200 +0xce
github.com/lxn/walk.(*ToolTip).AddTool(0xc04206b440, 0x1400900, 0xc0421b6840, 0x495d8b8, 0xc0423a1738)
	src/github.com/lxn/walk/tooltip.go:179 +0x4b
github.com/lxn/walk.(*WidgetBase).init(0xc0421b6840, 0x13ff600, 0xc0421b6840, 0x13ff600, 0xc0421b6840)
	src/github.com/lxn/walk/widget.go:117 +0x4e
github.com/lxn/walk.InitWindow(0x495d6c0, 0xc0421b6840, 0x13fbfa0, 0xc042029500, 0xe67e61, 0x1c, 0x1000050000000, 0x0, 0x0)
	src/github.com/lxn/walk/window.go:453 +0x941
github.com/lxn/walk.InitWidget(0x13ff600, 0xc0421b6840, 0x13fbfa0, 0xc042029500, 0xe67e61, 0x1c, 0x1000050000000, 0xe2dea0, 0xe4b1a0)
	src/github.com/lxn/walk/widget.go:96 +0xc5
github.com/lxn/walk.NewCompositeWithStyle(0x13fbfa0, 0xc042029500, 0xc000000000, 0x13fbfa0, 0xc042029500, 0x13fe620)
	src/github.com/lxn/walk/composite.go:28 +0xf5
github.com/lxn/walk.NewComposite(0x13fe620, 0xc042029500, 0xc042029500, 0x13fe620, 0xc042029500)
	src/github.com/lxn/walk/composite.go:43 +0x68
github.com/lxn/walk.(*FormBase).init(0xc042029500, 0x495d408, 0xc042029500, 0x495d408, 0xc042029500)
	src/github.com/lxn/walk/form.go:107 +0x78
github.com/lxn/walk.InitWindow(0x13fbfa0, 0xc042029500, 0x0, 0x0, 0xe68b66, 0x1d, 0x1000000cf0000, 0x0, 0x0)
	src/github.com/lxn/walk/window.go:445 +0x9c5
github.com/lxn/walk.NewMainWindow(0x0, 0x0, 0x0)
	src/github.com/lxn/walk/mainwindow.go:34 +0xba
main.runMenu(0x0, 0x0)
	main.go:49 +0x56
main.main()
	main.go:182 +0x3df

I thought maybe this is because the main window wasn't being created from the main thread, but I tried to call runtime.LockOSThread() and it made no difference.

@tmm1
Copy link
Contributor Author

tmm1 commented Oct 31, 2017

I'm not sure what was causing this, but I moved the walk.NewMainWindow() call to be the first thing in my main() and now it works. I think perhaps one of my other dependencies was interacting with the windows api as well and conflicting somehow.

@tmm1 tmm1 closed this as completed Oct 31, 2017
@tmm1 tmm1 reopened this Nov 1, 2017
@tmm1
Copy link
Contributor Author

tmm1 commented Nov 1, 2017

I figured out why this is happening.. one of my dependencies uses go-ole, which calls Lock/UnlockOSThread itself. This causes the main thread to get unlocked due to a golang bug.

See golang/go#20458 which has been fixed in hyangah/go@97af9ea for golang 1.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant