Skip to content

client: Fix infinite recursion with text-input-v2

It was possible to get into an infinite recursion when
double-clicking an entry in an item view to edit it.

What would happen is that the editor takes focus, and we call
commit on the input method commit in case the previous focused
widget has pending input that needs to be committed. The
subsequent method event then causes the QAbstractItemView to
set focus, and since we have not yet updated the focus in the
previous call, we end up in an infinite recursion, eventually
crashing when the stack overflows.

As a guard for this, we only send an input method event when there
is actually pre-edit text to commit, and we reset the pre-edit
text immediately so that any subsequent call will just exit.

[ChangeLog][QtWaylandClient] Fixed a possible crash when editing
a field in an item view.

Pick-to: 5.15 6.2 6.4 6.5
Fixes: QTBUG-109302
Change-Id: I45237c80e53b1386705279899e19319180d78fa1
Reviewed-by: Liang Qi <>
Reviewed-by: Paul Olav Tvete <>
Reviewed-by: Inho Lee <>
(cherry picked from commit db4afd9caf037cfff7aca8b130d326c340b7fed0)

* asturmlechner 2023-08-14: Resolve conflict with dev branch commit
  af8f8c33ea885f472682f98e0699721f50b1f020 - change applied in
  qwaylandinputcontext.cpp instead.

Even if the upstream commit is addressing QWaylandTextInputv2::commit() - after making up for af8f8c33, it turns out this applies 1:1 over QWaylandTextInput::commit() and seems to be just as valid there.

Merge request reports