summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-01-12 14:56:18 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-02-02 07:55:32 +0100
commit28a0b1dc46d1324356e8bcad7004303171c3f1a6 (patch)
treea20a65e514369cbd2e25d744f60dac01948820e9
parent4a8dc948412112202e235eb27f9eb35d7b3b8c3b (diff)
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. Fixes: QTBUG-109302 Change-Id: I45237c80e53b1386705279899e19319180d78fa1 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Inho Lee <inho.lee@qt.io> (cherry picked from commit db4afd9caf037cfff7aca8b130d326c340b7fed0)
-rw-r--r--src/client/qwaylandinputcontext.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp
index 9f883b171..015fa9573 100644
--- a/src/client/qwaylandinputcontext.cpp
+++ b/src/client/qwaylandinputcontext.cpp
@@ -93,9 +93,12 @@ void QWaylandTextInput::reset()
void QWaylandTextInput::commit()
{
if (QObject *o = QGuiApplication::focusObject()) {
- QInputMethodEvent event;
- event.setCommitString(m_preeditCommit);
- QCoreApplication::sendEvent(o, &event);
+ if (!m_preeditCommit.isEmpty()) {
+ QInputMethodEvent event;
+ event.setCommitString(m_preeditCommit);
+ m_preeditCommit = QString();
+ QCoreApplication::sendEvent(o, &event);
+ }
}
reset();