]> git.sesse.net Git - movit/commit
Use thread-local locale.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 3 Mar 2015 22:03:54 +0000 (23:03 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 3 Mar 2015 22:10:39 +0000 (23:10 +0100)
commit401c6ca91cf582904cf38d6bfe1d82a073eff559
treee8f87f1206cab4128c8b87e33da21c1410588ba2
parent1400c353ad03f4d31f665be0d02e8e360f69ef5c
Use thread-local locale.

setlocale() affects the whole process, not just the current thread
as I assumed; uselocale() (available since glibc 2.3, so basically
forever) is per-thread, and also conveniently seems to avoid the
issue of the returned pointer being destroyed (unless the driver
uses the return value of uselocale() as a base, which I really hope
it doesn't).

I'm slightly worried that since this overrides setlocale(), buggy drivers
might get confused when they try to do setlocale() and something else
overrides that precedence, but hopefully this shouldn't be a case.

Also add a unit test for locale handling while we're at it. It doesn't
test multi-threaded behavior, though, only the simple case.

Reported by Christophe Thommeret.
effect_chain.cpp
effect_chain_test.cpp