Rename remaining QEvent variables to m_ convention; init m_reserved

Change-Id: I08694657b7c9d2713d0cb33519698dbba3bfdffa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Shawn Rutledge 2020-11-09 16:03:59 +01:00
parent 88efeb9e25
commit ef051a61f6
8 changed files with 41 additions and 39 deletions

View File

@ -492,7 +492,7 @@ void QCoreApplicationPrivate::cleanupThreadData()
const QPostEvent &pe = thisThreadData->postEventList.at(i); const QPostEvent &pe = thisThreadData->postEventList.at(i);
if (pe.event) { if (pe.event) {
--pe.receiver->d_func()->postedEvents; --pe.receiver->d_func()->postedEvents;
pe.event->posted = false; pe.event->m_posted = false;
delete pe.event; delete pe.event;
} }
} }
@ -1050,7 +1050,7 @@ bool QCoreApplication::notifyInternal2(QObject *receiver, QEvent *event)
bool QCoreApplication::forwardEvent(QObject *receiver, QEvent *event, QEvent *originatingEvent) bool QCoreApplication::forwardEvent(QObject *receiver, QEvent *event, QEvent *originatingEvent)
{ {
if (event && originatingEvent) if (event && originatingEvent)
event->spont = originatingEvent->spont; event->m_spont = originatingEvent->m_spont;
return notifyInternal2(receiver, event); return notifyInternal2(receiver, event);
} }
@ -1431,7 +1431,7 @@ bool QCoreApplication::sendEvent(QObject *receiver, QEvent *event)
Q_TRACE(QCoreApplication_sendEvent, receiver, event, event->type()); Q_TRACE(QCoreApplication_sendEvent, receiver, event, event->type());
if (event) if (event)
event->spont = false; event->m_spont = false;
return notifyInternal2(receiver, event); return notifyInternal2(receiver, event);
} }
@ -1443,7 +1443,7 @@ bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event)
Q_TRACE(QCoreApplication_sendSpontaneousEvent, receiver, event, event->type()); Q_TRACE(QCoreApplication_sendSpontaneousEvent, receiver, event, event->type());
if (event) if (event)
event->spont = true; event->m_spont = true;
return notifyInternal2(receiver, event); return notifyInternal2(receiver, event);
} }
@ -1563,7 +1563,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
Q_TRACE(QCoreApplication_postEvent_event_posted, receiver, event, event->type()); Q_TRACE(QCoreApplication_postEvent_event_posted, receiver, event, event->type());
data->postEventList.addEvent(QPostEvent(receiver, event, priority)); data->postEventList.addEvent(QPostEvent(receiver, event, priority));
eventDeleter.take(); eventDeleter.take();
event->posted = true; event->m_posted = true;
++receiver->d_func()->postedEvents; ++receiver->d_func()->postedEvents;
data->canWait = false; data->canWait = false;
locker.unlock(); locker.unlock();
@ -1774,7 +1774,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
// first, we diddle the event so that we can deliver // first, we diddle the event so that we can deliver
// it, and that no one will try to touch it later. // it, and that no one will try to touch it later.
pe.event->posted = false; pe.event->m_posted = false;
QEvent *e = pe.event; QEvent *e = pe.event;
QObject * r = pe.receiver; QObject * r = pe.receiver;
@ -1844,7 +1844,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
if ((!receiver || pe.receiver == receiver) if ((!receiver || pe.receiver == receiver)
&& (pe.event && (eventType == 0 || pe.event->type() == eventType))) { && (pe.event && (eventType == 0 || pe.event->type() == eventType))) {
--pe.receiver->d_func()->postedEvents; --pe.receiver->d_func()->postedEvents;
pe.event->posted = false; pe.event->m_posted = false;
events.append(pe.event); events.append(pe.event);
const_cast<QPostEvent &>(pe).event = nullptr; const_cast<QPostEvent &>(pe).event = nullptr;
} else if (!data->postEventList.recursion) { } else if (!data->postEventList.recursion) {
@ -1881,7 +1881,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
void QCoreApplicationPrivate::removePostedEvent(QEvent * event) void QCoreApplicationPrivate::removePostedEvent(QEvent * event)
{ {
if (!event || !event->posted) if (!event || !event->m_posted)
return; return;
QThreadData *data = QThreadData::current(); QThreadData *data = QThreadData::current();
@ -1906,7 +1906,7 @@ void QCoreApplicationPrivate::removePostedEvent(QEvent * event)
pe.receiver->objectName().toLocal8Bit().data()); pe.receiver->objectName().toLocal8Bit().data());
#endif #endif
--pe.receiver->d_func()->postedEvents; --pe.receiver->d_func()->postedEvents;
pe.event->posted = false; pe.event->m_posted = false;
delete pe.event; delete pe.event;
const_cast<QPostEvent &>(pe).event = nullptr; const_cast<QPostEvent &>(pe).event = nullptr;
return; return;

View File

@ -120,7 +120,7 @@ public:
bool sendThroughApplicationEventFilters(QObject *, QEvent *); bool sendThroughApplicationEventFilters(QObject *, QEvent *);
static bool sendThroughObjectEventFilters(QObject *, QEvent *); static bool sendThroughObjectEventFilters(QObject *, QEvent *);
static bool notify_helper(QObject *, QEvent *); static bool notify_helper(QObject *, QEvent *);
static inline void setEventSpontaneous(QEvent *e, bool spontaneous) { e->spont = spontaneous; } static inline void setEventSpontaneous(QEvent *e, bool spontaneous) { e->m_spont = spontaneous; }
virtual void createEventDispatcher(); virtual void createEventDispatcher();
virtual void eventDispatcherReady(); virtual void eventDispatcherReady();

View File

@ -865,7 +865,7 @@ void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerI
&& (pe.event->type() == QEvent::Timer || pe.event->type() == QEvent::ZeroTimerEvent) && (pe.event->type() == QEvent::Timer || pe.event->type() == QEvent::ZeroTimerEvent)
&& static_cast<QTimerEvent *>(pe.event)->timerId() == timerId) { && static_cast<QTimerEvent *>(pe.event)->timerId() == timerId) {
--pe.receiver->d_func()->postedEvents; --pe.receiver->d_func()->postedEvents;
pe.event->posted = false; pe.event->m_posted = false;
delete pe.event; delete pe.event;
const_cast<QPostEvent &>(pe).event = 0; const_cast<QPostEvent &>(pe).event = 0;
return; return;

View File

@ -294,8 +294,9 @@ QT_BEGIN_NAMESPACE
Contructs an event object of type \a type. Contructs an event object of type \a type.
*/ */
QEvent::QEvent(Type type) QEvent::QEvent(Type type)
: d(nullptr), t(type), posted(false), spont(false), m_accept(true), : d(nullptr), t(type), m_posted(false), m_spont(false), m_accept(true),
m_inputEvent(false), m_pointerEvent(false), m_singlePointEvent(false) m_inputEvent(false), m_pointerEvent(false), m_singlePointEvent(false),
m_reserved(0)
{ {
Q_TRACE(QEvent_ctor, this, t); Q_TRACE(QEvent_ctor, this, t);
} }
@ -305,9 +306,10 @@ QEvent::QEvent(Type type)
Copies the \a other event. Copies the \a other event.
*/ */
QEvent::QEvent(const QEvent &other) QEvent::QEvent(const QEvent &other)
: d(other.d), t(other.t), posted(other.posted), spont(other.spont), : d(other.d), t(other.t), m_posted(other.m_posted), m_spont(other.m_spont),
m_accept(other.m_accept), m_inputEvent(other.m_inputEvent), m_accept(other.m_accept), m_inputEvent(other.m_inputEvent),
m_pointerEvent(other.m_pointerEvent), m_singlePointEvent(other.m_singlePointEvent) m_pointerEvent(other.m_pointerEvent), m_singlePointEvent(other.m_singlePointEvent),
m_reserved(other.m_reserved)
{ {
Q_TRACE(QEvent_ctor, this, t); Q_TRACE(QEvent_ctor, this, t);
// if QEventPrivate becomes available, make sure to implement a // if QEventPrivate becomes available, make sure to implement a
@ -355,8 +357,8 @@ QEvent &QEvent::operator=(const QEvent &other)
Q_ASSERT_X(!other.d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere"); Q_ASSERT_X(!other.d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere");
t = other.t; t = other.t;
posted = other.posted; m_posted = other.m_posted;
spont = other.spont; m_spont = other.m_spont;
m_accept = other.m_accept; m_accept = other.m_accept;
return *this; return *this;
} }
@ -369,7 +371,7 @@ QEvent &QEvent::operator=(const QEvent &other)
QEvent::~QEvent() QEvent::~QEvent()
{ {
Q_TRACE(QEvent_dtor, this, t); Q_TRACE(QEvent_dtor, this, t);
if (posted && QCoreApplication::instance()) if (m_posted && QCoreApplication::instance())
QCoreApplicationPrivate::removePostedEvent(this); QCoreApplicationPrivate::removePostedEvent(this);
Q_ASSERT_X(!d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere"); Q_ASSERT_X(!d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere");
} }

View File

@ -298,7 +298,7 @@ public:
virtual ~QEvent(); virtual ~QEvent();
QEvent &operator=(const QEvent &other); QEvent &operator=(const QEvent &other);
inline Type type() const { return static_cast<Type>(t); } inline Type type() const { return static_cast<Type>(t); }
inline bool spontaneous() const { return spont; } inline bool spontaneous() const { return m_spont; }
inline virtual void setAccepted(bool accepted) { m_accept = accepted; } inline virtual void setAccepted(bool accepted) { m_accept = accepted; }
inline bool isAccepted() const { return m_accept; } inline bool isAccepted() const { return m_accept; }
@ -323,13 +323,13 @@ protected:
quint16 t; quint16 t;
private: private:
quint16 posted : 1; quint16 m_posted : 1;
quint16 spont : 1; quint16 m_spont : 1;
quint16 m_accept : 1; quint16 m_accept : 1;
quint16 m_inputEvent : 1; quint16 m_inputEvent : 1;
quint16 m_pointerEvent : 1; quint16 m_pointerEvent : 1;
quint16 m_singlePointEvent : 1; quint16 m_singlePointEvent : 1;
quint16 reserved : 10; quint16 m_reserved : 10;
friend class QCoreApplication; friend class QCoreApplication;
friend class QCoreApplicationPrivate; friend class QCoreApplicationPrivate;
@ -345,7 +345,7 @@ private:
friend class QSpontaneKeyEvent; friend class QSpontaneKeyEvent;
// needs this: // needs this:
Q_ALWAYS_INLINE Q_ALWAYS_INLINE
void setSpontaneous() { spont = true; } void setSpontaneous() { m_spont = true; }
}; };
class Q_CORE_EXPORT QTimerEvent : public QEvent class Q_CORE_EXPORT QTimerEvent : public QEvent

View File

@ -97,7 +97,7 @@ QThreadData::~QThreadData()
const QPostEvent &pe = postEventList.at(i); const QPostEvent &pe = postEventList.at(i);
if (pe.event) { if (pe.event) {
--pe.receiver->d_func()->postedEvents; --pe.receiver->d_func()->postedEvents;
pe.event->posted = false; pe.event->m_posted = false;
delete pe.event; delete pe.event;
} }
} }

View File

@ -1254,7 +1254,7 @@ bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event)
bool spont = event->spontaneous(); bool spont = event->spontaneous();
if (spont ? qt_sendSpontaneousEvent(o, event) : QCoreApplication::sendEvent(o, event)) if (spont ? qt_sendSpontaneousEvent(o, event) : QCoreApplication::sendEvent(o, event))
return true; return true;
event->spont = spont; event->m_spont = spont;
} }
return item->sceneEvent(event); return item->sceneEvent(event);
} }
@ -1443,7 +1443,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// event is converted to a press. Known limitation: // event is converted to a press. Known limitation:
// Triple-clicking will not generate a doubleclick, though. // Triple-clicking will not generate a doubleclick, though.
QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress); QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress);
mousePress.spont = mouseEvent->spont; mousePress.m_spont = mouseEvent->spontaneous();
mousePress.accept(); mousePress.accept();
mousePress.setButton(mouseEvent->button()); mousePress.setButton(mouseEvent->button());
mousePress.setButtons(mouseEvent->buttons()); mousePress.setButtons(mouseEvent->buttons());
@ -6032,7 +6032,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
} else { } else {
item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted); item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
} }
touchEvent->spont = false; touchEvent->m_spont = false;
if (res && eventAccepted) { if (res && eventAccepted) {
// the first item to accept the TouchBegin gets an implicit grab. // the first item to accept the TouchBegin gets an implicit grab.
const auto &touchPoints = touchEvent->points(); const auto &touchPoints = touchEvent->points();

View File

@ -2842,7 +2842,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
while (w) { while (w) {
QMouseEvent me(mouse->type(), relpos, mouse->scenePosition(), mouse->globalPosition().toPoint(), QMouseEvent me(mouse->type(), relpos, mouse->scenePosition(), mouse->globalPosition().toPoint(),
mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source()); mouse->button(), mouse->buttons(), mouse->modifiers(), mouse->source());
me.spont = mouse->spontaneous(); me.m_spont = mouse->spontaneous();
me.setTimestamp(mouse->timestamp()); me.setTimestamp(mouse->timestamp());
QMutableSinglePointEvent::from(me).setDoubleClick(QMutableSinglePointEvent::from(mouse)->isDoubleClick()); QMutableSinglePointEvent::from(me).setDoubleClick(QMutableSinglePointEvent::from(mouse)->isDoubleClick());
// throw away any mouse-tracking-only mouse events // throw away any mouse-tracking-only mouse events
@ -2854,7 +2854,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
} else { } else {
w->setAttribute(Qt::WA_NoMouseReplay, false); w->setAttribute(Qt::WA_NoMouseReplay, false);
res = d->notify_helper(w, w == receiver ? mouse : &me); res = d->notify_helper(w, w == receiver ? mouse : &me);
e->spont = false; e->m_spont = false;
} }
eventAccepted = (w == receiver ? mouse : &me)->isAccepted(); eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
if (res && eventAccepted) if (res && eventAccepted)
@ -2970,7 +2970,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
we.setTimestamp(wheel->timestamp()); we.setTimestamp(wheel->timestamp());
bool eventAccepted; bool eventAccepted;
do { do {
we.spont = wheel->spontaneous() && w == receiver; we.m_spont = wheel->spontaneous() && w == receiver;
res = d->notify_helper(w, &we); res = d->notify_helper(w, &we);
eventAccepted = we.isAccepted(); eventAccepted = we.isAccepted();
if (res && eventAccepted) if (res && eventAccepted)
@ -2994,10 +2994,10 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
bool eventAccepted = context->isAccepted(); bool eventAccepted = context->isAccepted();
while (w) { while (w) {
QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers()); QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
ce.spont = e->spontaneous(); ce.m_spont = e->spontaneous();
res = d->notify_helper(w, w == receiver ? context : &ce); res = d->notify_helper(w, w == receiver ? context : &ce);
eventAccepted = ((w == receiver) ? context : &ce)->isAccepted(); eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
e->spont = false; e->m_spont = false;
if ((res && eventAccepted) if ((res && eventAccepted)
|| w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
@ -3024,11 +3024,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
tablet->pressure(), tablet->xTilt(), tablet->yTilt(), tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
tablet->tangentialPressure(), tablet->rotation(), tablet->z(), tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
tablet->modifiers(), tablet->button(), tablet->buttons()); tablet->modifiers(), tablet->button(), tablet->buttons());
te.spont = e->spontaneous(); te.m_spont = e->spontaneous();
te.setAccepted(false); te.setAccepted(false);
res = d->notify_helper(w, w == receiver ? tablet : &te); res = d->notify_helper(w, w == receiver ? tablet : &te);
eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted(); eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
e->spont = false; e->m_spont = false;
if ((res && eventAccepted) if ((res && eventAccepted)
|| w->isWindow() || w->isWindow()
|| w->testAttribute(Qt::WA_NoMousePropagation)) || w->testAttribute(Qt::WA_NoMousePropagation))
@ -3053,9 +3053,9 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
bool eventAccepted = help->isAccepted(); bool eventAccepted = help->isAccepted();
while (w) { while (w) {
QHelpEvent he(help->type(), relpos, help->globalPos()); QHelpEvent he(help->type(), relpos, help->globalPos());
he.spont = e->spontaneous(); he.m_spont = e->spontaneous();
res = d->notify_helper(w, w == receiver ? help : &he); res = d->notify_helper(w, w == receiver ? help : &he);
e->spont = false; e->m_spont = false;
eventAccepted = (w == receiver ? help : &he)->isAccepted(); eventAccepted = (w == receiver ? help : &he)->isAccepted();
if ((res && eventAccepted) || w->isWindow()) if ((res && eventAccepted) || w->isWindow())
break; break;
@ -3175,7 +3175,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
} else { } else {
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted); widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
} }
touchEvent->spont = false; touchEvent->m_spont = false;
if (res && eventAccepted) { if (res && eventAccepted) {
// the first widget to accept the TouchBegin gets an implicit grab. // the first widget to accept the TouchBegin gets an implicit grab.
d->activateImplicitTouchGrab(widget, touchEvent); d->activateImplicitTouchGrab(widget, touchEvent);
@ -3271,11 +3271,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
if (!gestures.isEmpty()) { // we have gestures for this w if (!gestures.isEmpty()) { // we have gestures for this w
QGestureEvent ge(gestures); QGestureEvent ge(gestures);
ge.t = gestureEvent->t; ge.t = gestureEvent->t;
ge.spont = gestureEvent->spont; ge.m_spont = gestureEvent->spontaneous();
ge.m_accept = wasAccepted; ge.m_accept = wasAccepted;
ge.m_accepted = gestureEvent->m_accepted; ge.m_accepted = gestureEvent->m_accepted;
res = d->notify_helper(w, &ge); res = d->notify_helper(w, &ge);
gestureEvent->spont = false; gestureEvent->m_spont = false;
eventAccepted = ge.isAccepted(); eventAccepted = ge.isAccepted();
for (int i = 0; i < gestures.size(); ++i) { for (int i = 0; i < gestures.size(); ++i) {
QGesture *g = gestures.at(i); QGesture *g = gestures.at(i);