fix: crash on startup in X11 (#35092)

Fixes #34996.

Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot]
2022-07-27 11:09:11 +02:00
committed by GitHub
parent 09c4fdd6d0
commit 215ae2b012

View File

@@ -278,12 +278,6 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
}
int ElectronBrowserMainParts::PreCreateThreads() {
#if defined(USE_AURA)
if (!display::Screen::GetScreen()) {
screen_ = views::CreateDesktopScreen();
}
#endif
if (!views::LayoutProvider::Get())
layout_provider_ = std::make_unique<views::LayoutProvider>();
@@ -314,6 +308,14 @@ int ElectronBrowserMainParts::PreCreateThreads() {
// Load resources bundle according to locale.
std::string loaded_locale = LoadResourceBundle(locale);
#if defined(USE_AURA)
// NB: must be called _after_ locale resource bundle is loaded,
// because ui lib makes use of it in X11
if (!display::Screen::GetScreen()) {
screen_ = views::CreateDesktopScreen();
}
#endif
// Initialize the app locale.
std::string app_locale = l10n_util::GetApplicationLocale(loaded_locale);
ElectronBrowserClient::SetApplicationLocale(app_locale);