diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-16 15:21:40 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-19 03:16:48 +0000 |
commit | 19f9b0d5f54379151eb71e98555b203ad6756276 (patch) | |
tree | 226f5dc2b77292146a0e42dba6fda6a807df7174 /src/plugins/platforms/android | |
parent | c149fd232daa4c62b0c39d603fe660104ceb92b5 (diff) |
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 <lars.knoll@qt.io>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
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 } }); |