summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qsoftkeymanager.cpp
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2010-07-02 16:16:59 +0200
committerJason Barron <jbarron@trolltech.com>2010-07-07 09:32:39 +0200
commit28651cfc0ce2954c0b6c0e5d3587e4d8b001c1de (patch)
tree2641e96621eb66099e43b3ad6a57146fa5de0f3d /src/gui/kernel/qsoftkeymanager.cpp
parent19f55bfa5bf15b5593f3021071374dbe2f71f8c8 (diff)
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
Diffstat (limited to 'src/gui/kernel/qsoftkeymanager.cpp')
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index 04e4685825..54e6317489 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