From 19f9b0d5f54379151eb71e98555b203ad6756276 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 16 Nov 2020 15:21:40 +0100 Subject: Disable copying and assigning of QEvent Polymorphic classes should not be copied. However, we do rely on event copying in our propagation logic. So, make the members protected, don't delete them, using a dedicated macro. This way, QMutable*Event classes can be used to make copies. Remove some last usage of copying of QInputMethod(Query)Events. Change-Id: Ia0a8ae4ca9de97dcd7788ca3c6ed930b6460c43a Reviewed-by: Lars Knoll --- .../platforms/android/qandroidinputcontext.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/android') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 689da5c136..0bd3205e50 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -1453,12 +1453,11 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur else m_composingCursor = -1; - QInputMethodEvent event; if (focusObjectIsComposing()) { QTextCharFormat underlined; underlined.setFontUnderline(true); - event = QInputMethodEvent(m_composingText, { + QInputMethodEvent event(m_composingText, { { QInputMethodEvent::TextFormat, 0, int(m_composingText.length()), underlined }, { QInputMethodEvent::Cursor, m_composingCursor - m_composingTextStart, 1 } }); @@ -1467,8 +1466,12 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur event.setCommitString({}, m_composingTextStart - effectiveAbsoluteCursorPos, oldComposingTextLen); } + if (m_composingText.isEmpty()) + clear(); + + QGuiApplication::sendEvent(m_focusObject, &event); } else { - event = QInputMethodEvent({}, {}); + QInputMethodEvent event({}, {}); if (focusObjectWasComposing) { event.setCommitString(m_composingText); @@ -1477,12 +1480,11 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur m_composingTextStart - effectiveAbsoluteCursorPos, oldComposingTextLen); } - } - - if (m_composingText.isEmpty()) - clear(); + if (m_composingText.isEmpty()) + clear(); - QGuiApplication::sendEvent(m_focusObject, &event); + QGuiApplication::sendEvent(m_focusObject, &event); + } if (!focusObjectIsComposing() && newCursorPosition != 1) { // Move cursor using a separate event because if we have inserted or deleted a newline @@ -1491,7 +1493,7 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur const int newBlockPos = getBlockPosition( focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImAbsolutePosition)); - event = QInputMethodEvent({}, { + QInputMethodEvent event({}, { { QInputMethodEvent::Selection, newAbsoluteCursorPos - newBlockPos, 0 } }); -- cgit v1.2.3