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

chore: Resolve warning gtk_disable_setlocale() must be called before gtk_init() #672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

polarathene
Copy link

Description

A warning is logged advising to explicitly opt-out of GTK setting the locale. This is relevant when you manage locale setting yourself (like open-vm-tools appears to):

# Generated service from `vmware-user.desktop` by `systemd-xdg-autostart-generator`:
$ systemctl --user status "app-vmware\x2duser@autostart.service"
vmtoolsd[947]: gtk_disable_setlocale() must be called before gtk_init()

# CLI command:
$ vmtoolsd -n vmusr --blockFd 3
Gtk-WARNING **: 17:53:50.082: gtk_disable_setlocale() must be called before gtk_init()

Reasoning

GTK docs gtk_disable_setlocale():

Prevents gtk_init(), gtk_init_check(), gtk_init_with_args() and gtk_parse_args() from automatically calling setlocale(LC_ALL, "").
You would want to use this function if you wanted to set the locale for your program to something other than the user’s locale, or if you wanted to set different values for different locale categories.

Most programs should not need to call this function.

A grep for locale shows quite a bit of explicit handling by open-vm-tools codebase, including setting setlocale(LC_ALL, "") itself. Here's an example for vmtoolsd:

NOTE: I've not compiled this change to verify. I've just seen it present over the years and thought I'd look into it and provide a PR that should resolve it. There is no harm with ignoring the warning AFAIK, the PR would just resolve some log noise that I've seen contribute some confusion to users that notice it while troubleshooting.

A warning is logged advising to explicitly opt-out of GTK setting the locale. This is relevant when you manage locale setting yourself:

https://docs.gtk.org/gtk3/func.disable_setlocale.html
@jonathanvmw
Copy link
Contributor

@polarathene Thanks for your contribution. Your contribution will go through a review process at VMware. An update will be provided once the review is completed.

@polarathene
Copy link
Author

@jonathanvmw friendly ping. Is a review still in the works?

@jonathanvmw
Copy link
Contributor

@polarathene

Thanks for the ping. I'm following up internally to try to get you an update. I'll also follow up on the two other issues you highlighted (#670 and #668) - hope to get you some feedback in the next couple of weeks.

@polarathene
Copy link
Author

polarathene commented Dec 3, 2023

hope to get you some feedback in the next couple of weeks.

Friendly ping @jonathanvmw any updates?

@gauravjvmw
Copy link

@polarathene Hey, We compiled the change and tried it on Ubuntu focal 20.04, but after that we could see the same warning coming up. So we are suspecting single 1 liner change is not complete fix for this.

result

@polarathene
Copy link
Author

So we are suspecting single 1 liner change is not complete fix for this.

That's unfortunate, no worries, should this issue be closed or is it something that'll continue to be looked into?


#668 is probably fine to address in the meantime?

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.

3 participants