diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2009-10-27 09:30:25 (GMT) |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2009-10-27 09:32:48 (GMT) |
commit | a36ee30a9753c766be1017550df581ab941b87e3 (patch) | |
tree | 77190785985054e0407c4c084d31eabe0e1124c0 /src/gui/inputmethod | |
parent | f5398e1adc5203b3aa56d50ee3a9bd936531a119 (diff) | |
download | Qt-a36ee30a9753c766be1017550df581ab941b87e3.zip Qt-a36ee30a9753c766be1017550df581ab941b87e3.tar.gz Qt-a36ee30a9753c766be1017550df581ab941b87e3.tar.bz2 |
Temporary fix for FEP crash with input masked QLineEdits
QLineEdits with input masks report the cursor position relative to
displayed text via inputMethodQuery(), but the text returned is
the actual text of the control, which can differ from displayed text,
causing mismatch between FEP display and control display.
To properly fix this we would need to know the displayText of
QLineEdits instead of just the text, which on itself should be a trivial
change. The difficulties start when we need to commit the changes back
to the QLineEdit, which would have to be somehow able to handle
displayText, too.
Task made to fix this properly: QTBUG-5050
Task-number: QTBUG-4892
Reviewed-by: axis
Diffstat (limited to 'src/gui/inputmethod')
-rw-r--r-- | src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index c4d17ff..3f21bc3 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -561,8 +561,28 @@ void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSele int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + m_preeditString.size(); int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt() + m_preeditString.size(); - aCursorSelection.iAnchorPos = anchor; - aCursorSelection.iCursorPos = cursor; + QString text = w->inputMethodQuery(Qt::ImSurroundingText).value<QString>(); + int combinedSize = text.size() + m_preeditString.size(); + if (combinedSize < anchor || combinedSize < cursor) { + // ### TODO! FIXME! QTBUG-5050 + // This is a hack to prevent crashing in 4.6 with QLineEdits that use input masks. + // The root problem is that cursor position is relative to displayed text instead of the + // actual text we get. + // + // To properly fix this we would need to know the displayText of QLineEdits instead + // of just the text, which on itself should be a trivial change. The difficulties start + // when we need to commit the changes back to the QLineEdit, which would have to be somehow + // able to handle displayText, too. + // + // Until properly fixed, the cursor and anchor positions will not reflect correct positions + // for masked QLineEdits, unless all the masked positions are filled in order so that + // cursor position relative to the displayed text matches position relative to actual text. + aCursorSelection.iAnchorPos = combinedSize; + aCursorSelection.iCursorPos = combinedSize; + } else { + aCursorSelection.iAnchorPos = anchor; + aCursorSelection.iCursorPos = cursor; + } } void QCoeFepInputContext::GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, |