tdesktop/Telegram/SourceFiles/platform/linux
Gleb Smirnoff 720f238cf8 Close a race between Gio threads and Qt application init.
QApplication has a historical feature[1] of calling setlocale(3) at init,
which today cause more harm than good.  Such call isn't thread safe neither
per C standard, not per any known libc implementation.  The Gio threads
would call into locale reading functions all the time, so early access to
locale by Gio may race with setlocale() by Qt leading to undefined behavior.

Platform specific start before the Sandbox (aka QApplication) is at core
design of tdesktop and that order can't be changed. There is no way to pause
Gio until QApplication instantiates.

Fortunately, Qt library itself has a static global flag that prevents it
from calling setlocale() twice. We don't even need to instantiate a
temporary QCoreApplication, we can just call into the method.  So call
it form Platform::start before any existing or future calls to Gio.

Fixes #16922

[1] https://chat.stackoverflow.com/rooms/63812/discussion-between-phil-armstrong-and-matteo-italia
2021-09-10 13:18:20 +03:00
..
file_utilities_linux.cpp Get rid of gtk open with dialog 2021-08-25 12:52:43 +03:00
file_utilities_linux.h Move EscapeShell to specific_linux 2021-01-22 17:22:37 +04:00
launcher_linux.cpp Remove unneeded libraries from snapcraft.yaml 2021-09-07 23:40:08 +03:00
launcher_linux.h Allow to build with -Werror and clang 2021-07-13 21:32:06 +03:00
linux_desktop_environment.cpp Avoid multiple .arg usage as suggested by clazy 2021-03-13 19:08:33 +03:00
linux_desktop_environment.h Get system icon theme on gtk-based DEs 2020-06-01 18:19:34 +04:00
linux_wayland_integration_dummy.cpp Switch MainWindow to Ui::RpWindow 2021-07-28 18:05:39 +03:00
linux_wayland_integration.cpp Switch MainWindow to Ui::RpWindow 2021-07-28 18:05:39 +03:00
linux_wayland_integration.h Switch MainWindow to Ui::RpWindow 2021-07-28 18:05:39 +03:00
linux_xdp_file_dialog.cpp Fix -Wunused-variable warnings with gcc 2021-07-19 22:31:27 +03:00
linux_xdp_file_dialog.h Make Linux file dialog API better 2021-06-24 11:26:24 +04:00
linux_xdp_open_with_dialog.cpp Use gsl::finally to pop thread context where appropriate 2021-07-02 20:11:28 +03:00
linux_xdp_open_with_dialog.h Add portal-based open with dialog implementation 2021-03-10 09:46:13 +04:00
main_window_linux.cpp Use Communications category for tray icon 2021-08-10 15:42:21 +03:00
main_window_linux.h Revert "Use QMenuBar instead of own global menu implementation on Linux" 2021-07-05 21:01:20 +03:00
notifications_manager_linux_dummy.cpp Fix build with dummy notifications manager on Linux. 2021-04-29 11:21:57 +04:00
notifications_manager_linux.cpp Add additional checks to NotificationData::setImage 2021-07-19 22:56:38 +03:00
notifications_manager_linux.h Move weak_ptr include to .cpp in linux notifications 2021-05-03 14:39:24 +03:00
specific_linux.cpp Close a race between Gio threads and Qt application init. 2021-09-10 13:18:20 +03:00
specific_linux.h Fix crash dump generation on Linux. 2021-05-03 17:34:33 +04:00