summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-02-19 11:41:12 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-30 18:47:02 +0000
commit3aa1b351d0487346c8d8514239f161360cade686 (patch)
tree6034f0346705e6414988f003df52f4678f8e1222
parenta9dc43b8c98fa0140522e661c4cf4b4f77dd0346 (diff)
Fix race condition when attaching client to text input
Extensions are registered by initialize(), which is called as a polish event later. Therefore the following race can happen: 1. Application #1 requests a text-input object. The compositor sees that the seat has no such object and creates a new one. 2. Polish event is posted. 3. Application #2 requests a text-input object. Since the polish event is not yet processed, it also creates a new one. 4. Second polish event posted. 5. Both polish events processed. We end up with two competing text-input objects, one per client. This in turn leads to enter/leave events not being sent correctly, and the client may therefore end up not updating the keyboard hints. The result was arbitrary behavior: Sometimes the keyboard would not open at all, whereas other times it would open with the current input method hints, even if these do not match the hints of the editor. [ChangeLog][Input] Fixed a problem where a virtual keyboard would not be updated correctly if two clients were started at almost the same time. Fixes: QTBUG-91096 Change-Id: I262a5c15f87ba13d750425c259583919cd947ea4 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> (cherry picked from commit e08b25efe4a7bec1004696bd23d9f8959158bd60) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp2
-rw-r--r--src/compositor/extensions/qwaylandtextinputmanager.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp
index b37c1a9b8..271c3ec52 100644
--- a/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp
+++ b/src/compositor/extensions/qwaylandqttextinputmethodmanager.cpp
@@ -50,6 +50,8 @@ void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_t
if (textInput == nullptr)
textInput = new QWaylandQtTextInputMethod(seat, compositor);
textInput->add(resource->client(), id, wl_resource_get_version(resource->handle));
+ if (!textInput->isInitialized())
+ textInput->initialize();
}
/*!
diff --git a/src/compositor/extensions/qwaylandtextinputmanager.cpp b/src/compositor/extensions/qwaylandtextinputmanager.cpp
index 495ebae84..d9938d1f3 100644
--- a/src/compositor/extensions/qwaylandtextinputmanager.cpp
+++ b/src/compositor/extensions/qwaylandtextinputmanager.cpp
@@ -51,6 +51,8 @@ void QWaylandTextInputManagerPrivate::zwp_text_input_manager_v2_get_text_input(R
textInput = new QWaylandTextInput(seat, compositor);
}
textInput->add(resource->client(), id, wl_resource_get_version(resource->handle));
+ if (!textInput->isInitialized())
+ textInput->initialize();
}
QWaylandTextInputManager::QWaylandTextInputManager()