Fix potential crash in accessibility key event handling
Change-Id: Id3eec6c83d7f8ece186e6b5bc02771c00893294b Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
parent
56820382f2
commit
d8e784f47e
@ -174,7 +174,7 @@ bool QSpiApplicationAdaptor::eventFilter(QObject *target, QEvent *event)
|
||||
SLOT(notifyKeyboardListenerError(QDBusError, QDBusMessage)), timeout);
|
||||
if (sent) {
|
||||
//queue the event and send it after callback
|
||||
keyEvents.enqueue(QPair<QObject*, QKeyEvent*> (target, copyKeyEvent(keyEvent)));
|
||||
keyEvents.enqueue(QPair<QPointer<QObject>, QKeyEvent*> (QPointer<QObject>(target), copyKeyEvent(keyEvent)));
|
||||
#ifdef KEYBOARD_DEBUG
|
||||
qDebug() << QStringLiteral("Sent key: ") << de.text;
|
||||
#endif
|
||||
@ -200,11 +200,12 @@ void QSpiApplicationAdaptor::notifyKeyboardListenerCallback(const QDBusMessage&
|
||||
}
|
||||
Q_ASSERT(message.arguments().length() == 1);
|
||||
if (message.arguments().at(0).toBool() == true) {
|
||||
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
|
||||
QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue();
|
||||
delete event.second;
|
||||
} else {
|
||||
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
|
||||
QCoreApplication::postEvent(event.first, event.second);
|
||||
QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue();
|
||||
if (event.first)
|
||||
QCoreApplication::postEvent(event.first.data(), event.second);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,8 +213,9 @@ void QSpiApplicationAdaptor::notifyKeyboardListenerError(const QDBusError& error
|
||||
{
|
||||
qWarning() << QStringLiteral("QSpiApplication::keyEventError ") << error.name() << error.message();
|
||||
while (!keyEvents.isEmpty()) {
|
||||
QPair<QObject*, QKeyEvent*> event = keyEvents.dequeue();
|
||||
QCoreApplication::postEvent(event.first, event.second);
|
||||
QPair<QPointer<QObject>, QKeyEvent*> event = keyEvents.dequeue();
|
||||
if (event.first)
|
||||
QCoreApplication::postEvent(event.first.data(), event.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#ifndef Q_SPI_APPLICATION_H
|
||||
#define Q_SPI_APPLICATION_H
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QQueue>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtGui/QAccessibleInterface>
|
||||
@ -76,7 +77,7 @@ private Q_SLOTS:
|
||||
private:
|
||||
static QKeyEvent* copyKeyEvent(QKeyEvent*);
|
||||
|
||||
QQueue<QPair<QObject*, QKeyEvent*> > keyEvents;
|
||||
QQueue<QPair<QPointer<QObject>, QKeyEvent*> > keyEvents;
|
||||
QDBusConnection dbusConnection;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user