mappu / miqt

MIT-licensed Qt bindings for Go
MIT License
273 stars 10 forks source link

Call runtime.LockOSThread automatically in NewQApplication #72

Open mappu opened 1 week ago

mappu commented 1 week ago

Wow. Indeed, calling runtime.LockOSThread() before NewQApplication seems to make it always work.

Originally posted by @ilius in https://github.com/mappu/miqt/discussions/68#discussioncomment-11202894

ilius commented 5 days ago

Although if NewQApplication itself is called in another function which is called in main(), this may not fix the problem (I had that issue in FreeBSD). I think runtime.LockOSThread() should be called directly inside main().

mappu commented 11 hours ago

@ilius Are you sure?

The documentation for LockOSThread says it should affect the entire goroutine indefinitely. It doesn't stop taking effect when returning from the function, it only stops taking effect when explicitly unlocking with UnlockOSThread.

But, real experience beats documentation.

Sorry to bother you but since I can't currently reproduce this, would you be able to remove your own calls to LockOSThread and try the branch from #83 ?

ilius commented 11 minutes ago

I got this error with #84 on FreeBSD. https://gist.github.com/ilius/48a96df3d4acd5cb06757f77dcbb7ceb

Then I ran sudo rm -rf $GOPATH/pkg/mod/github.com/mappu/miqt\@v0.* and go build again, but it finished quickly. So I ran rm -rf ~/.cache/go-build/ and go build again, and I got the same error as above.