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

Call runtime.LockOSThread() automatically for the Qt main thread #83

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

mappu
Copy link
Owner

@mappu mappu commented Nov 18, 2024

Fixes: #72

@jamalsa
Copy link
Contributor

jamalsa commented Nov 18, 2024

Shouldn't we call runtime.LockOSThread() in init function on qt/qt6 package like shown here: https://go.dev/wiki/LockOSThread? This way we don't need to have a separate call in three places.

@mappu
Copy link
Owner Author

mappu commented Nov 19, 2024

The most important thing is that the goroutine that calls LockOSThread is the same one that calls NewQApplication:

  • For most MIQT apps, I expect NewQApplication would be called early in main, and so putting LockOSThread in init as per the wiki would have the same effect.
  • But, in some cases it might be possible that NewQApplication is called a long time after init. For example, if some app is mostly a non-Qt app (e.g. a daemon) and only initializes a Qt GUI in response to some later event. In that case, LockOSThread would not match correctly.

So I think it's safer to do it this way. The code in three places is not a maintenance problem, since it's autogenerated, and it exists only in one place in the generator. Although for binary size reasons, maybe it would be nice to have only one.

@mappu mappu merged commit 47d4581 into master Nov 19, 2024
10 checks passed
@mappu mappu deleted the miqt-lockosthread branch November 19, 2024 05:23
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

Successfully merging this pull request may close these issues.

Call runtime.LockOSThread automatically in NewQApplication
2 participants