Skip to content

Commit

Permalink
Reduce amount of tracepoints required for event tracking
Browse files Browse the repository at this point in the history
Encode the consumed/filtered state in the _exit tracepoint and remove
the separate tracking of receiver event handling. Combined, this
reduces the size of the trace file.

Change-Id: Icb3cb2dd47798543905cea450046d6fad559a15b
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
milianw committed May 2, 2019
1 parent bfe8b50 commit 75634c9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
20 changes: 9 additions & 11 deletions src/corelib/kernel/qcoreapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,28 +1197,26 @@ bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event)
{
// Note: when adjusting the tracepoints in here
// consider adjusting QApplicationPrivate::notify_helper too.
Q_TRACE_SCOPE(QCoreApplication_notify, receiver, event, event->type());
Q_TRACE(QCoreApplication_notify_entry, receiver, event, event->type());
bool consumed = false;
bool filtered = false;
Q_TRACE_EXIT(QCoreApplication_notify_exit, consumed, filtered);

// send to all application event filters (only does anything in the main thread)
if (QCoreApplication::self
&& receiver->d_func()->threadData->thread == mainThread()
&& QCoreApplication::self->d_func()->sendThroughApplicationEventFilters(receiver, event)) {
Q_TRACE(QCoreApplication_notify_event_filtered, receiver, event, event->type());
return true;
filtered = true;
return filtered;
}
// send to all receiver event filters
if (sendThroughObjectEventFilters(receiver, event)) {
Q_TRACE(QCoreApplication_notify_event_filtered, receiver, event, event->type());
return true;
filtered = true;
return filtered;
}

Q_TRACE(QCoreApplication_notify_before_delivery, receiver, event, event->type());

// deliver the event
const bool consumed = receiver->event(event);

Q_TRACE(QCoreApplication_notify_after_delivery, receiver, event, event->type(), consumed);

consumed = receiver->event(event);
return consumed;
}

Expand Down
5 changes: 1 addition & 4 deletions src/corelib/qtcore.tracepoints
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ QCoreApplication_sendEvent(QObject *receiver, QEvent *event, int type)
QCoreApplication_sendSpontaneousEvent(QObject *receiver, QEvent *event, int type)

QCoreApplication_notify_entry(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_exit()
QCoreApplication_notify_event_filtered(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_before_delivery(QObject *receiver, QEvent *event, int type)
QCoreApplication_notify_after_delivery(QObject *receiver, QEvent *event, int type, bool consumed)
QCoreApplication_notify_exit(bool consumed, bool filtered)

QObject_ctor(QObject *object)
QObject_dtor(QObject *object)
Expand Down
19 changes: 9 additions & 10 deletions src/widgets/kernel/qapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3697,14 +3697,17 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
// to the ones in QCoreApplicationPrivate::notify_helper; the reason for their
// duplication is because tracepoint symbols are not exported by QtCore.
// If you adjust the tracepoints here, consider adjusting QCoreApplicationPrivate too.
Q_TRACE_SCOPE(QApplication_notify, receiver, e, e->type());
Q_TRACE(QApplication_notify_entry, receiver, e, e->type());
bool consumed = false;
bool filtered = false;
Q_TRACE_EXIT(QApplication_notify_exit, consumed, filtered);

// send to all application event filters
if (threadRequiresCoreApplication()
&& receiver->d_func()->threadData->thread == mainThread()
&& sendThroughApplicationEventFilters(receiver, e)) {
Q_TRACE(QApplication_notify_event_filtered, receiver, e, e->type());
return true;
filtered = true;
return filtered;
}

if (receiver->isWidgetType()) {
Expand All @@ -3726,16 +3729,12 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)

// send to all receiver event filters
if (sendThroughObjectEventFilters(receiver, e)) {
Q_TRACE(QApplication_notify_event_filtered, receiver, e, e->type());
return true;
filtered = true;
return filtered;
}

Q_TRACE(QApplication_notify_before_delivery, receiver, e, e->type());

// deliver the event
const bool consumed = receiver->event(e);

Q_TRACE(QApplication_notify_after_delivery, receiver, e, e->type(), consumed);
consumed = receiver->event(e);

QCoreApplicationPrivate::setEventSpontaneous(e, false);
return consumed;
Expand Down
5 changes: 1 addition & 4 deletions src/widgets/qtwidgets.tracepoints
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ QT_END_NAMESPACE
}

QApplication_notify_entry(QObject *receiver, QEvent *event, int type)
QApplication_notify_exit()
QApplication_notify_event_filtered(QObject *receiver, QEvent *event, int type)
QApplication_notify_before_delivery(QObject *receiver, QEvent *event, int type)
QApplication_notify_after_delivery(QObject *receiver, QEvent *event, int type, bool consumed)
QApplication_notify_exit(bool consumed, bool filtered)

0 comments on commit 75634c9

Please sign in to comment.