From c7edb365f6c9c3d614fb6bb2fe03de3dd6d2d5a8 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Thu, 2 Mar 2017 16:47:29 +0100 Subject: Fix browser process crash when IBus is enabled Change-Id: Ic48b34473c808bcfdc80acdccab4883a8e9d5715 Reviewed-by: Allan Sandfeld Jensen --- src/core/render_widget_host_view_qt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 46057c3e4..870b19eef 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -823,14 +823,22 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) case Qt::ImFont: return QVariant(); case Qt::ImCursorRectangle: + // QIBusPlatformInputContext might query ImCursorRectangle before the + // RenderWidgetHostView is created. Without an available view GetSelectionRange() + // returns nullptr. + if (!GetTextInputManager()->GetSelectionRegion()) + return QVariant(); return toQt(GetTextInputManager()->GetSelectionRegion()->caret_rect); case Qt::ImCursorPosition: + Q_ASSERT(GetTextInputManager()->GetSelectionRegion()); return toQt(GetTextInputManager()->GetSelectionRegion()->focus.edge_top_rounded().x()); case Qt::ImAnchorPosition: + Q_ASSERT(GetTextInputManager()->GetSelectionRegion()); return toQt(GetTextInputManager()->GetSelectionRegion()->anchor.edge_top_rounded().x()); case Qt::ImSurroundingText: return m_surroundingText; case Qt::ImCurrentSelection: { + Q_ASSERT(GetTextInputManager()->GetTextSelection()); base::string16 text; GetTextInputManager()->GetTextSelection()->GetSelectedText(&text); return toQt(text); -- cgit v1.2.3