Skip to content

Commit

Permalink
ozone/x11: Fix an IME-related crash during browser initialization
Browse files Browse the repository at this point in the history
Recent changes in LinuxInputMethodContextFactory initialization (see
crrev.com/c/2062974) broke ozone/x11. After it, browser crashes at
startup. This fixes it as well as adds DCHECK to make sure
LinuxInputMethodContextFactory is correctly set just after LinuxUI
initialization.

Bug: 1055061
Change-Id: Iefe5acc48ec9047b90042b398159e9b260a753f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2069229
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Maksim Sisov <msisov@igalia.com>
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744902}
  • Loading branch information
nickdiego authored and Commit Bot committed Feb 27, 2020
1 parent 2af9e7e commit 182d586
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ void ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized() {

views::LinuxUI::SetInstance(linux_ui);
linux_ui->Initialize();

DCHECK(ui::LinuxInputMethodContextFactory::instance())
<< "LinuxUI must set LinuxInputMethodContextFactory instance.";
}
7 changes: 7 additions & 0 deletions ui/ozone/platform/x11/ozone_platform_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "base/message_loop/message_pump_type.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/ime/linux/linux_input_method_context_factory.h"
#include "ui/base/x/x11_util.h"
#include "ui/display/fake/fake_display_delegate.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
Expand Down Expand Up @@ -114,6 +115,12 @@ class OzonePlatformX11 : public OzonePlatform {
#if defined(OS_CHROMEOS)
return std::make_unique<InputMethodChromeOS>(delegate);
#else
// This method is used by upper layer components (e.g: GtkUi) to determine
// if the LinuxInputMethodContextFactory instance is provided by the Ozone
// platform implementation, so we must consider the case that it is still
// not set at this point.
if (!ui::LinuxInputMethodContextFactory::instance())
return nullptr;
return std::make_unique<InputMethodAuraLinux>(delegate);
#endif
}
Expand Down

0 comments on commit 182d586

Please sign in to comment.