AyuGramDesktop/Telegram/SourceFiles/platform
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
..
linux Close a race between Gio threads and Qt application init. 2021-09-10 13:18:20 +03:00
mac Appended references to const auto types in loop to prevent copying. 2021-09-09 16:32:04 +03:00
win Use QOperatingSystemVersion. 2021-09-01 18:33:53 +03:00
platform_audio.h Use Q_OS_UNIX instead of Q_OS_LINUX since linux-specific code can be used also on *BSD/Haiku 2020-06-17 20:33:23 +04:00
platform_file_bookmark.h Move Media::Clip::Reader and FileLocation to td_ui. 2020-10-30 18:32:18 +03:00
platform_file_utilities.h Use some methods from lib_base 2020-10-30 10:52:49 +03:00
platform_launcher.h Use Q_OS_UNIX instead of Q_OS_LINUX since linux-specific code can be used also on *BSD/Haiku 2020-06-17 20:33:23 +04:00
platform_main_window.h Use Q_OS_UNIX instead of Q_OS_LINUX since linux-specific code can be used also on *BSD/Haiku 2020-06-17 20:33:23 +04:00
platform_notifications_manager.h Respect Focus Assist only for native notifications. 2021-04-28 11:20:39 +04:00
platform_specific.h Revert "Use gtk clipboard when available to avoid https://bugreports.qt.io/browse/QTBUG-56595" 2021-08-12 08:51:10 +03:00
platform_window_title.h Switch MainWindow to Ui::RpWindow 2021-07-28 18:05:39 +03:00