diff options
author | Janne Anttila <janne.anttila@digia.com> | 2010-03-02 08:56:03 (GMT) |
---|---|---|
committer | Janne Anttila <janne.anttila@digia.com> | 2010-03-02 09:00:44 (GMT) |
commit | 94b2938086203bc6154b107c518df7a6fbfb4b2c (patch) | |
tree | 9fc300b245d9abad0b7f1dee2bbb3870c3d81c4c /src | |
parent | 440d6d764d2b13ab9f70675bc3b15806de63f005 (diff) | |
download | Qt-94b2938086203bc6154b107c518df7a6fbfb4b2c.zip Qt-94b2938086203bc6154b107c518df7a6fbfb4b2c.tar.gz Qt-94b2938086203bc6154b107c518df7a6fbfb4b2c.tar.bz2 |
Fixed FEP crash when selected text was replaced with a a new T9 text.
In T9 input mode StartFepInlineEditL gets called with empty initial
text. In case there was text selected in editor when editing started,
the selected text did not get removed since the logic in editors to
detect input is as follows:
bool isGettingInput = !event->commitString().isEmpty()
|| event->preeditString() != preeditAreaText()
|| event->replacementLength() > 0;
This means that empty preeditString did not trigger selection removal,
but the selected text was removed when non-empty inline text was
provided by UpdateFepInlineTextL. However, the S60 FEP assumes that
StartFepInlineEditL removes the selected text, i.e
GetCursorSelectionForFep after StartFepInlineEditL must return empty
selection.
The above issue was fixed by removing the selected text explicitly in
StartFepInlineEditL if aInitialInlineText is empty.
Task-number: QTBUG-6363
Reviewed-by: Axis
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 1ac8ace..cc60246 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -551,6 +551,21 @@ void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText, m_formatRetriever = &aInlineTextFormatRetriever; m_pointerHandler = &aPointerEventHandlerDuringInlineEdit; + // With T9 aInitialInlineText is typically empty when StartFepInlineEditL is called, + // but FEP requires that selected text is always removed at StartFepInlineEditL. + // Let's remove the selected text if aInitialInlineText is empty and there is selected text + if (m_preeditString.isEmpty()) { + int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); + int replacementLength = qAbs(m_cursorPos-anchor); + if (replacementLength > 0) { + int replacementStart = m_cursorPos < anchor ? 0 : -replacementLength; + QList<QInputMethodEvent::Attribute> clearSelectionAttributes; + QInputMethodEvent clearSelectionEvent(QLatin1String(""), clearSelectionAttributes); + clearSelectionEvent.setCommitString(QLatin1String(""), replacementStart, replacementLength); + sendEvent(clearSelectionEvent); + } + } + applyFormat(&attributes); attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, |