QAccessibleWidget: fix UB (invalid cast)
Casting an object to a subclass that is not the dynamic type of the object constitutes undefined behavior. Fix by befriending QObject. Change-Id: Ib70dbef9095df31a6d89449d82a02cef9fccd348 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>bb10
parent
2f672b2239
commit
7993cada39
|
|
@ -71,6 +71,7 @@ class QObjectPrivate;
|
|||
class QObject;
|
||||
class QThread;
|
||||
class QWidget;
|
||||
class QAccessibleWidget;
|
||||
#ifndef QT_NO_REGEXP
|
||||
class QRegExp;
|
||||
#endif
|
||||
|
|
@ -459,6 +460,7 @@ protected:
|
|||
friend class QCoreApplication;
|
||||
friend class QCoreApplicationPrivate;
|
||||
friend class QWidget;
|
||||
friend class QAccessibleWidget;
|
||||
friend class QThreadData;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -273,22 +273,6 @@ QRect QAccessibleWidget::rect() const
|
|||
return QRect(wpos.x(), wpos.y(), w->width(), w->height());
|
||||
}
|
||||
|
||||
QT_BEGIN_INCLUDE_NAMESPACE
|
||||
#include <private/qobject_p.h>
|
||||
QT_END_INCLUDE_NAMESPACE
|
||||
|
||||
class QACConnectionObject : public QObject
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QObject)
|
||||
public:
|
||||
inline bool isSender(const QObject *receiver, const char *signal) const
|
||||
{ return d_func()->isSender(receiver, signal); }
|
||||
inline QObjectList receiverList(const char *signal) const
|
||||
{ return d_func()->receiverList(signal); }
|
||||
inline QObjectList senderList() const
|
||||
{ return d_func()->senderList(); }
|
||||
};
|
||||
|
||||
/*!
|
||||
Registers \a signal as a controlling signal.
|
||||
|
||||
|
|
@ -347,9 +331,9 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
|
|||
|
||||
if (match & QAccessible::Controlled) {
|
||||
QObjectList allReceivers;
|
||||
QACConnectionObject *connectionObject = (QACConnectionObject*)object();
|
||||
QObject *connectionObject = object();
|
||||
for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
|
||||
const QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toLatin1());
|
||||
const QObjectList receivers = connectionObject->d_func()->receiverList(d->primarySignals.at(sig).toLatin1());
|
||||
allReceivers += receivers;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue