diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-04-16 15:44:16 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-07-18 02:24:45 +0000 |
commit | 9d98584a835962ca7ad870bbede8f6ab7f66b6bf (patch) | |
tree | 6d001b43665f04733c904eb67d101494846abbe1 /src/corelib/kernel/qcoreapplication.cpp | |
parent | 01f800ae6f8611a4218b7bbf5953dc896cac5767 (diff) |
Make the event delivery go through some more static functions
This commit makes QCoreApplicationPrivate::checkReceiverThread,
notify_helper, and sendThroughObjectEventFilters be static functions,
since they only deal with global data or the parameters only.
Making notifyInternal would have been binary incompatible (it's called
from inline functions QCoreApplication::sendSpontaneousEvent and
QCoreApplication::sendEvent), so instead add a new static
notifyInternal2 and mark the older function deprecated and to be removed
in Qt 6.
Change-Id: I27eaacb532114dd188c4ffff13d59fe3b0661489
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 08c0473cf0..e47dc0dff2 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -940,12 +941,28 @@ void QCoreApplication::setQuitLockEnabled(bool enabled) /*! \internal + \deprecated This function is here to make it possible for Qt extensions to hook into event notification without subclassing QApplication */ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event) { + return notifyInternal2(receiver, event); +} + +/*! + \internal + \since 5.6 + + This function is here to make it possible for Qt extensions to + hook into event notification without subclassing QApplication. +*/ +bool QCoreApplication::notifyInternal2(QObject *receiver, QEvent *event) +{ + if (!self) + return false; + // Make it possible for Qt Script to hook into events even // though QApplication is subclassed... bool result = false; @@ -961,10 +978,9 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event) QObjectPrivate *d = receiver->d_func(); QThreadData *threadData = d->threadData; QScopedLoopLevelCounter loopLevelCounter(threadData); - return notify(receiver, event); + return self->notify(receiver, event); } - /*! Sends \a event to \a receiver: \a {receiver}->event(\a event). Returns the value that is returned from the receiver's event @@ -1020,7 +1036,6 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event) bool QCoreApplication::notify(QObject *receiver, QEvent *event) { - Q_D(QCoreApplication); // no events are delivered after ~QCoreApplication() has started if (QCoreApplicationPrivate::is_app_closing) return true; @@ -1031,10 +1046,10 @@ bool QCoreApplication::notify(QObject *receiver, QEvent *event) } #ifndef QT_NO_DEBUG - d->checkReceiverThread(receiver); + QCoreApplicationPrivate::checkReceiverThread(receiver); #endif - return receiver->isWidgetType() ? false : d->notify_helper(receiver, event); + return receiver->isWidgetType() ? false : QCoreApplicationPrivate::notify_helper(receiver, event); } bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event) @@ -1058,8 +1073,7 @@ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiv bool QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject *receiver, QEvent *event) { - Q_Q(QCoreApplication); - if (receiver != q && receiver->d_func()->extraData) { + if (receiver != QCoreApplication::instance() && receiver->d_func()->extraData) { for (int i = 0; i < receiver->d_func()->extraData->eventFilters.size(); ++i) { QObject *obj = receiver->d_func()->extraData->eventFilters.at(i); if (!obj) @@ -1078,12 +1092,12 @@ bool QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject *receiver, Q /*! \internal - Helper function called by notify() + Helper function called by QCoreApplicationPrivate::notify() and qapplication.cpp */ bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event) { - // send to all application event filters - if (sendThroughApplicationEventFilters(receiver, event)) + // send to all application event filters (only does anything in the main thread) + if (QCoreApplication::self->d_func()->sendThroughApplicationEventFilters(receiver, event)) return true; // send to all receiver event filters if (sendThroughObjectEventFilters(receiver, event)) |