gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
https://gtk-rs.org/
MIT License
1.24k stars 82 forks source link

Possible bug with simultaneous work "gtk-rs" and "xlsxwriter-rs" crates #1043

Closed dgr113 closed 4 years ago

dgr113 commented 4 years ago

If I run a function that writes in Excel BEFORE running the GTK GUI the numeric data is written correctly. But if I start writing AFTER GUI... then f64 numbers are written as integers =(

My GIT example

EDIT: "LC_ALL=C" compilation env set helped me. This was suggested to me by "gtk-rs" maintainers. Thanks to them =)

sdroege commented 4 years ago

I assume it's enough to run gtk::init() and all the other pieces are not required?

This is definitely not a bug in the bindings, but still quite curious :) I would guess this happens because GTK is initializing things for i18n and xlswriter-rs (libxlswriter probably) somehow gets influenced by that. Maybe because in your locale numbers are written 1,2 or 1.2 and that mixes up things.

You could also try running with LC_ALL=C to see if that makes a difference.

dgr113 commented 4 years ago

I have allocated excel export app into a separate process and this situation has not happened again. Although of course this is not a very convenient way...

GuillaumeGomez commented 4 years ago

Welcome to the C world, where non-related codes might collide because of dark magic.

dgr113 commented 4 years ago

I like your GTK project and sometimes I have to use export to Excel... it's sad that they can't be together yet =(

sdroege commented 4 years ago

Did you try with LC_ALL=C? In any case, it would be useful to report this to the libxlswriter project as that's most likely where the underlying bug is.

dgr113 commented 4 years ago

I'll do it today=) Thnx for your feedback!

GuillaumeGomez commented 4 years ago

@dgr113 If it doesn't need to be in the same process, you can just spawn another one which will run the excel export (like you did).

sdroege commented 4 years ago

I'll do it today=) Thnx for your feedback!

Thanks! Let me know what you find out and please also put the link to the libxlswriter issue here

dgr113 commented 4 years ago

LC_ALL=C

Hmm... it works! This may need to be included into package docs ? What do you think ?

sdroege commented 4 years ago

This only means that libxlswriter is broken and outputs data depending on the locale instead of what is expected for XLS. Standard issue with C libraries that assume the string formatting functions in C are locale-independent.

Please report this to libxlswriter and link to it here.