diff options
author | Liang Qi <liang.qi@qt.io> | 2019-05-02 09:39:31 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-05-02 09:39:31 +0200 |
commit | 166889ddcbaac91c403a840f138f25bc2907b68c (patch) | |
tree | e30d875586d782d2253b18c63e9829f246356665 /src/corelib | |
parent | ef05c48898e90e4ff40d8c4493f4b80bc22c1703 (diff) | |
parent | ef3daddae1720956e746142ac7ee54a27b9299d7 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
src/corelib/kernel/qobject.cpp
Change-Id: I8ca1163a1fa8072dcd16ea4426c58219149599fd
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qtrace_p.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 48 | ||||
-rw-r--r-- | src/corelib/qtcore.tracepoints | 20 |
3 files changed, 38 insertions, 32 deletions
diff --git a/src/corelib/global/qtrace_p.h b/src/corelib/global/qtrace_p.h index 20f2beac98..4cef126bb6 100644 --- a/src/corelib/global/qtrace_p.h +++ b/src/corelib/global/qtrace_p.h @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE const auto qTraceExit_ ## x ## __COUNTER__ = qScopeGuard([&]() { Q_TRACE(x, __VA_ARGS__); }); # define Q_TRACE_SCOPE(x, ...) \ Q_TRACE(x ## _entry, __VA_ARGS__); \ - Q_TRACE_EXIT(x ## _exit, __VA_ARGS__); + Q_TRACE_EXIT(x ## _exit); # define Q_UNCONDITIONAL_TRACE(x, ...) QtPrivate::do_trace_ ## x(__VA_ARGS__) # define Q_TRACE_ENABLED(x) QtPrivate::trace_ ## x ## _enabled() #else diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index d03b9fafb1..e6b313863f 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1445,8 +1445,9 @@ QThread *QObject::thread() const \snippet code/src_corelib_kernel_qobject.cpp 7 - If \a targetThread is zero, all event processing for this object - and its children stops. + If \a targetThread is \nullptr, all event processing for this object + and its children stops, as they are no longer associated with any + thread. Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with @@ -1457,13 +1458,18 @@ QThread *QObject::thread() const A QEvent::ThreadChange event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are - posted to this object will be handled in the \a targetThread. + posted to this object will be handled in the \a targetThread, + provided it is non-null: when it is \nullptr, no event processing + for this object or its children can happen, as they are no longer + associated with any thread. \warning This function is \e not thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary - thread to the current thread. + thread to the current thread. There is one exception to this rule + however: objects with no thread affinity can be "pulled" to the + current thread. \sa thread() */ @@ -3662,19 +3668,18 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i if (sender->d_func()->blockSig) return; + Q_TRACE_SCOPE(QMetaObject_activate, sender, signal_index); + if (sender->d_func()->isDeclarativeSignalConnected(signal_index) && QAbstractDeclarativeData::signalEmitted) { - Q_TRACE(QMetaObject_activate_begin_declarative_signal, sender, signal_index); + Q_TRACE_SCOPE(QMetaObject_activate_declarative_signal, sender, signal_index); QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv); - Q_TRACE(QMetaObject_activate_end_declarative_signal, sender, signal_index); } if (!sender->d_func()->isSignalConnected(signal_index, /*checkDeclarative =*/ false) && !qt_signal_spy_callback_set.signal_begin_callback - && !qt_signal_spy_callback_set.signal_end_callback - && !Q_TRACE_ENABLED(QMetaObject_activate_begin_signal) - && !Q_TRACE_ENABLED(QMetaObject_activate_end_signal)) { + && !qt_signal_spy_callback_set.signal_end_callback) { // The possible declarative connection is done, and nothing else is connected, so: return; } @@ -3686,7 +3691,6 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i if (qt_signal_spy_callback_set.signal_begin_callback != 0) { qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index, argv); } - Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index); { QMutexLocker locker(signalSlotLock(sender)); @@ -3717,7 +3721,6 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i locker.unlock(); if (qt_signal_spy_callback_set.signal_end_callback != 0) qt_signal_spy_callback_set.signal_end_callback(sender, signal_index); - Q_TRACE(QMetaObject_activate_end_signal, sender, signal_index); return; } @@ -3778,9 +3781,11 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i c->slotObj->ref(); QScopedPointer<QtPrivate::QSlotObjectBase, QSlotObjectBaseDeleter> obj(c->slotObj); locker.unlock(); - Q_TRACE(QMetaObject_activate_begin_slot_functor, obj.data()); - obj->call(receiver, argv); - Q_TRACE(QMetaObject_activate_end_slot_functor, obj.data()); + + { + Q_TRACE_SCOPE(QMetaObject_activate_slot_functor, obj.data()); + obj->call(receiver, argv); + } // Make sure the slot object gets destroyed before the mutex is locked again, as the // destructor of the slot object might also lock a mutex from the signalSlotLock() mutex pool, @@ -3796,11 +3801,12 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i locker.unlock(); if (qt_signal_spy_callback_set.slot_begin_callback != 0) qt_signal_spy_callback_set.slot_begin_callback(receiver, methodIndex, argv); - Q_TRACE(QMetaObject_activate_begin_slot, receiver, methodIndex); - callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv); + { + Q_TRACE_SCOPE(QMetaObject_activate_slot, receiver, methodIndex); + callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv); + } - Q_TRACE(QMetaObject_activate_end_slot, receiver, methodIndex); if (qt_signal_spy_callback_set.slot_end_callback != 0) qt_signal_spy_callback_set.slot_end_callback(receiver, methodIndex); locker.relock(); @@ -3811,11 +3817,12 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i if (qt_signal_spy_callback_set.slot_begin_callback != 0) { qt_signal_spy_callback_set.slot_begin_callback(receiver, method, argv); } - Q_TRACE(QMetaObject_activate_begin_slot, receiver, method); - metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv); + { + Q_TRACE_SCOPE(QMetaObject_activate_slot, receiver, method); + metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv); + } - Q_TRACE(QMetaObject_activate_end_slot, receiver, method); if (qt_signal_spy_callback_set.slot_end_callback != 0) qt_signal_spy_callback_set.slot_end_callback(receiver, method); @@ -3836,7 +3843,6 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i if (qt_signal_spy_callback_set.signal_end_callback != 0) qt_signal_spy_callback_set.signal_end_callback(sender, signal_index); - Q_TRACE(QMetaObject_activate_end_signal, sender, signal_index); } /*! diff --git a/src/corelib/qtcore.tracepoints b/src/corelib/qtcore.tracepoints index 3a70136741..a1bc957fe5 100644 --- a/src/corelib/qtcore.tracepoints +++ b/src/corelib/qtcore.tracepoints @@ -16,7 +16,7 @@ QEvent_ctor(QEvent *event, int type) QEvent_dtor(QEvent *event, int type) QCoreApplication_postEvent_entry(QObject *receiver, QEvent *event, int type) -QCoreApplication_postEvent_exit(QObject *receiver, QEvent *event, int type) +QCoreApplication_postEvent_exit() QCoreApplication_postEvent_event_compressed(QObject *receiver, QEvent *event) QCoreApplication_postEvent_event_posted(QObject *receiver, QEvent *event, int type) @@ -24,7 +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(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) @@ -32,13 +32,13 @@ QCoreApplication_notify_after_delivery(QObject *receiver, QEvent *event, int typ QObject_ctor(QObject *object) QObject_dtor(QObject *object) -QMetaObject_activate_begin_signal(QObject *sender, int signalIndex) -QMetaObject_activate_end_signal(QObject *sender, int signalIndex) -QMetaObject_activate_begin_slot(QObject *receiver, int slotIndex) -QMetaObject_activate_end_slot(QObject *receiver, int slotIndex) -QMetaObject_activate_begin_slot_functor(void *slotObject) -QMetaObject_activate_end_slot_functor(void *slotObject) -QMetaObject_activate_begin_declarative_signal(QObject *sender, int signalIndex) -QMetaObject_activate_end_declarative_signal(QObject *sender, int signalIndex) +QMetaObject_activate_entry(QObject *sender, int signalIndex) +QMetaObject_activate_exit() +QMetaObject_activate_slot_entry(QObject *receiver, int slotIndex) +QMetaObject_activate_slot_exit() +QMetaObject_activate_slot_functor_entry(void *slotObject) +QMetaObject_activate_slot_functor_exit() +QMetaObject_activate_declarative_signal_entry(QObject *sender, int signalIndex) +QMetaObject_activate_declarative_signal_exit() qt_message_print(int type, const char *category, const char *function, const char *file, int line, const QString &message) |