diff options
author | Sami Merila <sami.merila@nokia.com> | 2011-03-23 13:22:43 (GMT) |
---|---|---|
committer | Sami Merila <sami.merila@nokia.com> | 2011-03-23 13:22:43 (GMT) |
commit | 1dbd4a629bb5e2392bf2c7ea096ad3d77a265e5f (patch) | |
tree | f88e34edb8aa3b51178a68564ebecad2639f4e95 | |
parent | 2d2af1cac203bb5d47c6a4b1ce23930bdb03b996 (diff) | |
download | Qt-1dbd4a629bb5e2392bf2c7ea096ad3d77a265e5f.zip Qt-1dbd4a629bb5e2392bf2c7ea096ad3d77a265e5f.tar.gz Qt-1dbd4a629bb5e2392bf2c7ea096ad3d77a265e5f.tar.bz2 |
Prevent crash when connecting signal in splitview
If there is no focusitem when connecting a signal, splitview crashes.
This is caused by null pointer use. Prevent the crash by checking the
pointer.
Task-number: QTBUG-16572
Reviewed-by: Guoqing Zhang
-rw-r--r-- | src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 5fccf96..41abe95 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -410,8 +410,11 @@ void QCoeFepInputContext::resetSplitViewWidget(bool keepInputWidget) windowToMove->setUpdatesEnabled(false); if (!alwaysResize) { - if (gv->scene()) { - if (gv->scene()->focusItem()) + if (gv->scene() && gv->scene()->focusItem()) { + // Check if the widget contains cursorPositionChanged signal and disconnect from it. + QByteArray signal = QMetaObject::normalizedSignature(SIGNAL(cursorPositionChanged())); + int index = gv->scene()->focusItem()->toGraphicsObject()->metaObject()->indexOfSignal(signal.right(signal.length() - 1)); + if (index != -1) disconnect(gv->scene()->focusItem()->toGraphicsObject(), SIGNAL(cursorPositionChanged()), this, SLOT(translateInputWidget())); QGraphicsItem *rootItem; foreach (QGraphicsItem *item, gv->scene()->items()) { @@ -501,6 +504,13 @@ void QCoeFepInputContext::ensureFocusWidgetVisible(QWidget *widget) // states getting changed. if (!moveWithinVisibleArea) { + // Check if the widget contains cursorPositionChanged signal and connect to it. + QByteArray signal = QMetaObject::normalizedSignature(SIGNAL(cursorPositionChanged())); + if (gv->scene() && gv->scene()->focusItem()) { + int index = gv->scene()->focusItem()->toGraphicsObject()->metaObject()->indexOfSignal(signal.right(signal.length() - 1)); + if (index != -1) + connect(gv->scene()->focusItem()->toGraphicsObject(), SIGNAL(cursorPositionChanged()), this, SLOT(translateInputWidget())); + } S60->splitViewLastWidget = widget; m_splitViewPreviousWindowStates = windowToMove->windowState(); } @@ -537,13 +547,6 @@ void QCoeFepInputContext::ensureFocusWidgetVisible(QWidget *widget) } windowToMove->setUpdatesEnabled(true); } else { - if (!moveWithinVisibleArea) { - // Check if the widget contains cursorPositionChanged signal and connect to it. - const char *signal = QMetaObject::normalizedSignature(SIGNAL(cursorPositionChanged())).constData(); - int index = gv->scene()->focusItem()->toGraphicsObject()->metaObject()->indexOfSignal(signal + 1); - if (index != -1) - connect(gv->scene()->focusItem()->toGraphicsObject(), SIGNAL(cursorPositionChanged()), this, SLOT(translateInputWidget())); - } translateInputWidget(); } |