fix: crash on startup in X11 (#35075)

Fixes #34996.
This commit is contained in:
Charles Kerr 2022-07-26 23:44:44 -05:00 committed by GitHub
parent ff804e3a74
commit 62001dc6cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -278,12 +278,6 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
} }
int ElectronBrowserMainParts::PreCreateThreads() { int ElectronBrowserMainParts::PreCreateThreads() {
#if defined(USE_AURA)
if (!display::Screen::GetScreen()) {
screen_ = views::CreateDesktopScreen();
}
#endif
if (!views::LayoutProvider::Get()) if (!views::LayoutProvider::Get())
layout_provider_ = std::make_unique<views::LayoutProvider>(); layout_provider_ = std::make_unique<views::LayoutProvider>();
@ -314,6 +308,14 @@ int ElectronBrowserMainParts::PreCreateThreads() {
// Load resources bundle according to locale. // Load resources bundle according to locale.
std::string loaded_locale = LoadResourceBundle(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. // Initialize the app locale.
std::string app_locale = l10n_util::GetApplicationLocale(loaded_locale); std::string app_locale = l10n_util::GetApplicationLocale(loaded_locale);
ElectronBrowserClient::SetApplicationLocale(app_locale); ElectronBrowserClient::SetApplicationLocale(app_locale);