qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code


From: Alberto Garcia
Subject: Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code
Date: Wed, 26 Aug 2015 11:13:00 +0200
User-agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu)

On Tue 25 Aug 2015 09:54:42 AM CEST, Markus Armbruster wrote:

>> (D) Run in a controlled mixed locale
>>    GTK runs completely in the locale determined by setlocale() (since it
>> never has to display raw JSON)
>>    We fix our JSON output code to use thread-specific locale
>> manipulations to (temporarily) switch to C locale before printing JSON
>>
>> that way, GTK still shows full German formatting for any localized
>> message in the GUI that happens to print numbers, but the JSON output
>> (which is independent of the GUI) also behaves correctly as a C-only
>> entity.
>
> Switching back to C locale whenever some unwanted locale-dependency
> breaks the code is problematic, because it involves finding all the
> places that break, iteratively (euphemism for "we debug one breakage
> after the other, adding temporary locale switches as we go).

For some cases we probably don't even need to switch the locale. For the
JSON case cannot we just easily convert the QFloat into a string
ourselves without using printf's "%f" ?

That doesn't invalidate however your point.

> I'd feel much better about confining GTK in its own thread, and
> setting only that thread's locale.

I haven't digged much into that part of the QEMU code, but if my
assumptions are true I think we would need at least:

- A separate GMainContext with its own main loop
- Making sure that all the code that touches the UI runs from that
  thread.

This is in principle possible, but I fear that we might be opening a can
of worms.

Berto



reply via email to

[Prev in Thread] Current Thread [Next in Thread]