summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2010-07-02 14:16:59 (GMT)
committerJason Barron <jbarron@trolltech.com>2010-07-07 07:32:39 (GMT)
commit28651cfc0ce2954c0b6c0e5d3587e4d8b001c1de (patch)
tree2641e96621eb66099e43b3ad6a57146fa5de0f3d
parent19f55bfa5bf15b5593f3021071374dbe2f71f8c8 (diff)
downloadQt-28651cfc0ce2954c0b6c0e5d3587e4d8b001c1de.zip
Qt-28651cfc0ce2954c0b6c0e5d3587e4d8b001c1de.tar.gz
Qt-28651cfc0ce2954c0b6c0e5d3587e4d8b001c1de.tar.bz2
Fix crash when handleCommand() called before softkeys are updated
Softkeys are updated via a compressable event that is posted via the event loop. Since these events are not delivered immediately, there is a chance that a call to handleCommand() could happen before the softkeys have been updated which can lead to a crash if the previous QAction's have been deleted already since the data structure used by QSoftKeyManager is outdated. The likeliness of this is increased by the fact that S60 commands are normally sent from the WSERV active object which has a higher priority than the active object used by Qt's event loop which means commands will preempt the event loop. The fix is to introduce a flag that keeps track of pending update requests and if a command is received while there are outstanding requests, force the softkeys to be updated before handling the command. Task-number: QT-3571 Reviewed-by: axis
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp5
-rw-r--r--src/gui/kernel/qsoftkeymanager_common_p.h2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index 04e4685..54e6317 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -162,6 +162,7 @@ void QSoftKeyManager::sendKeyEvent()
void QSoftKeyManager::updateSoftKeys()
{
+ QSoftKeyManager::instance()->d_func()->pendingUpdate = true;
QEvent *event = new QEvent(QEvent::UpdateSoftKeys);
QApplication::postEvent(QSoftKeyManager::instance(), event);
}
@@ -250,6 +251,7 @@ bool QSoftKeyManager::handleUpdateSoftKeys()
}
d->updateSoftKeys_sys();
+ d->pendingUpdate = false;
return true;
}
@@ -275,6 +277,9 @@ bool QSoftKeyManager::event(QEvent *e)
#ifdef Q_WS_S60
bool QSoftKeyManager::handleCommand(int command)
{
+ if (QSoftKeyManager::instance()->d_func()->pendingUpdate)
+ (void)QSoftKeyManager::instance()->handleUpdateSoftKeys();
+
return static_cast<QSoftKeyManagerPrivateS60*>(QSoftKeyManager::instance()->d_func())->handleCommand(command);
}
#endif
diff --git a/src/gui/kernel/qsoftkeymanager_common_p.h b/src/gui/kernel/qsoftkeymanager_common_p.h
index 04ddf7d..1b364d4 100644
--- a/src/gui/kernel/qsoftkeymanager_common_p.h
+++ b/src/gui/kernel/qsoftkeymanager_common_p.h
@@ -71,7 +71,7 @@ protected:
QHash<QAction*, Qt::Key> keyedActions;
QMultiHash<int, QAction*> requestedSoftKeyActions;
QWidget *initialSoftKeySource;
-
+ bool pendingUpdate;
};
QT_END_NAMESPACE