diff options
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 34 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.h | 9 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication_p.h | 6 |
3 files changed, 33 insertions, 16 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)) diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 1009fe8439..d865c4e7a8 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -194,7 +194,10 @@ protected: private: #ifndef QT_NO_QOBJECT static bool sendSpontaneousEvent(QObject *receiver, QEvent *event); - bool notifyInternal(QObject *receiver, QEvent *event); +# if QT_DEPRECATED_SINCE(5,6) + QT_DEPRECATED bool notifyInternal(QObject *receiver, QEvent *event); // ### Qt6 BIC: remove me +# endif + static bool notifyInternal2(QObject *receiver, QEvent *); #endif void init(); @@ -221,10 +224,10 @@ private: #ifndef QT_NO_QOBJECT inline bool QCoreApplication::sendEvent(QObject *receiver, QEvent *event) -{ if (event) event->spont = false; return self ? self->notifyInternal(receiver, event) : false; } +{ if (event) event->spont = false; return notifyInternal2(receiver, event); } inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *event) -{ if (event) event->spont = true; return self ? self->notifyInternal(receiver, event) : false; } +{ if (event) event->spont = true; return notifyInternal2(receiver, event); } #endif #ifdef QT_NO_DEPRECATED diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 2646a28d71..5fed850c2b 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -86,8 +86,8 @@ public: #ifndef QT_NO_QOBJECT bool sendThroughApplicationEventFilters(QObject *, QEvent *); - bool sendThroughObjectEventFilters(QObject *, QEvent *); - bool notify_helper(QObject *, QEvent *); + static bool sendThroughObjectEventFilters(QObject *, QEvent *); + static bool notify_helper(QObject *, QEvent *); static inline void setEventSpontaneous(QEvent *e, bool spontaneous) { e->spont = spontaneous; } virtual void createEventDispatcher(); @@ -109,7 +109,7 @@ public: static QThread *mainThread(); static void sendPostedEvents(QObject *receiver, int event_type, QThreadData *data); - void checkReceiverThread(QObject *receiver); + static void checkReceiverThread(QObject *receiver); void cleanupThreadData(); #endif // QT_NO_QOBJECT |