Skip to content

Commit

Permalink
Fix crash due to dangling pointer access in developer mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Nov 15, 2024
1 parent 6eb8760 commit e2d1b8d
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/mixxxapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void MixxxApplication::registerMetaTypes() {
qRegisterMetaType<mixxx::FileInfo>("mixxx::FileInfo");
}

bool MixxxApplication::notify(QObject* target, QEvent* event) {
bool MixxxApplication::notify(QObject* pTarget, QEvent* event) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// All touch events are translated into two simultaneous events: one for
// the target QWidgetWindow and one for the target QWidget.
Expand Down Expand Up @@ -197,18 +197,27 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) {
time.start();
}

bool ret = QApplication::notify(target, event);

if (m_isDeveloper && time.elapsed() > kEventNotifyExecTimeWarningThreshold) {
qDebug() << "Processing event type"
<< event->type()
<< "for object"
<< target->metaObject()->className()
<< target->objectName()
<< "running in thread:"
<< target->thread()->objectName()
<< "took"
<< time.elapsed().debugMillisWithUnit();
bool ret = QApplication::notify(pTarget, event);

if (m_isDeveloper &&
time.elapsed() > kEventNotifyExecTimeWarningThreshold) {
if (event->type() == QEvent::DeferredDelete) {
// pTarget can be already dangling in case of DeferredDelete
qDebug() << "Processing QEvent::DeferredDelete"
<< "for object"
<< static_cast<void*>(pTarget) // will print dangling address
<< "took"
<< time.elapsed().debugMillisWithUnit();
} else {
qDebug() << "Processing"
<< event->type()
<< "for object"
<< pTarget // will print address, class and object name
<< "running in thread:"
<< pTarget->thread()->objectName()
<< "took"
<< time.elapsed().debugMillisWithUnit();
}
}

return ret;
Expand Down

0 comments on commit e2d1b8d

Please sign in to comment.