summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2009-10-01 10:41:23 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2009-10-01 10:43:32 (GMT)
commita7273386adb9399ecdc7b7c8f4b041099db042ef (patch)
tree2d0989705f411e43150fd289c72612f131658599
parenta542c1c7f5f49b0b5feb85d6ea56155e0cec411b (diff)
downloadQt-a7273386adb9399ecdc7b7c8f4b041099db042ef.zip
Qt-a7273386adb9399ecdc7b7c8f4b041099db042ef.tar.gz
Qt-a7273386adb9399ecdc7b7c8f4b041099db042ef.tar.bz2
Fix crash in S60 input methods after task switching
When switching away from the application, the focused widget is set to null. When switching back, there are callbacks from S60 before the focus has been restored. These functions check for null widget, but the output function parameters are left uninitialised, which causes a crash inside the S60 FEP. 1) GetXYZ functions now initialise the output parameters even when the focused widget is null. 2) Return no input capability when there is no focused widget, as was already done during destruction. This stops most of the callbacks from S60. Task-number: QTBUG-4618 Reviewed-by: axis
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index fc55a0f..c4d17ff 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -222,7 +222,7 @@ void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event)
TCoeInputCapabilities QCoeFepInputContext::inputCapabilities()
{
- if (m_inDestruction) {
+ if (m_inDestruction || !focusWidget()) {
return TCoeInputCapabilities(TCoeInputCapabilities::ENone, 0, 0);
}
@@ -554,8 +554,10 @@ void QCoeFepInputContext::SetCursorSelectionForFepL(const TCursorSelection& aCur
void QCoeFepInputContext::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
{
QWidget *w = focusWidget();
- if (!w)
+ if (!w) {
+ aCursorSelection.SetSelection(0,0);
return;
+ }
int cursor = w->inputMethodQuery(Qt::ImCursorPosition).toInt() + m_preeditString.size();
int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt() + m_preeditString.size();
@@ -567,8 +569,10 @@ void QCoeFepInputContext::GetEditorContentForFep(TDes& aEditorContent, TInt aDoc
TInt aLengthToRetrieve) const
{
QWidget *w = focusWidget();
- if (!w)
+ if (!w) {
+ aEditorContent.FillZ(aLengthToRetrieve);
return;
+ }
QString text = w->inputMethodQuery(Qt::ImSurroundingText).value<QString>();
// FEP expects the preedit string to be part of the editor content, so let's mix it in.
@@ -580,8 +584,10 @@ void QCoeFepInputContext::GetEditorContentForFep(TDes& aEditorContent, TInt aDoc
void QCoeFepInputContext::GetFormatForFep(TCharFormat& aFormat, TInt /* aDocumentPosition */) const
{
QWidget *w = focusWidget();
- if (!w)
+ if (!w) {
+ aFormat = TCharFormat();
return;
+ }
QFont font = w->inputMethodQuery(Qt::ImFont).value<QFont>();
QFontMetrics metrics(font);
@@ -595,8 +601,12 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin
TInt& aAscent, TInt /* aDocumentPosition */) const
{
QWidget *w = focusWidget();
- if (!w)
+ if (!w) {
+ aLeftSideOfBaseLine = TPoint(0,0);
+ aHeight = 0;
+ aAscent = 0;
return;
+ }
QRect rect = w->inputMethodQuery(Qt::ImMicroFocus).value<QRect>();
aLeftSideOfBaseLine.iX = rect.left();