Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qobject.cpp File Reference
#include "qobject.h"
#include "qobject_p.h"
#include "qobject_p_p.h"
#include "qmetaobject_p.h"
#include "qabstracteventdispatcher.h"
#include "qabstracteventdispatcher_p.h"
#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qcoreevent_p.h"
#include "qloggingcategory.h"
#include "qvariant.h"
#include "qmetaobject.h"
#include <qthread.h>
#include <private/qthread_p.h>
#include <qdebug.h>
#include <qpair.h>
#include <qvarlengtharray.h>
#include <qscopeguard.h>
#include <qset.h>
#include <private/qorderedmutexlocker_p.h>
#include <private/qhooks_p.h>
#include <qtcore_tracepoints_p.h>
#include <new>
#include <mutex>
#include <memory>
#include <ctype.h>
#include <limits.h>
#include "moc_qobject.cpp"
+ Include dependency graph for qobject.cpp:

Go to the source code of this file.

Classes

struct  SlotObjectGuard
 

Functions

QT_BEGIN_NAMESPACE Q_TRACE_POINT (qtcore, QObject_ctor, QObject *object)
 
 Q_TRACE_POINT (qtcore, QObject_dtor, QObject *object)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_entry, QObject *sender, int signalIndex)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_exit)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_slot_entry, QObject *receiver, int slotIndex)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_slot_exit)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_slot_functor_entry, void *slotObject)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_slot_functor_exit)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_declarative_signal_entry, QObject *sender, int signalIndex)
 
 Q_TRACE_POINT (qtcore, QMetaObject_activate_declarative_signal_exit)
 
void qt_register_signal_spy_callbacks (QSignalSpyCallbackSet *callback_set)
 
static int * queuedConnectionTypes (const QMetaMethod &method)
 
static int * queuedConnectionTypes (const QArgumentType *argumentTypes, int argc)
 
static QBasicMutexsignalSlotLock (const QObject *o)
 
static void computeOffsets (const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
 
static bool check_parent_thread (QObject *parent, QThreadData *parentThreadData, QThreadData *currentThreadData)
 
static void qt_qFindChildren_with_name (const QObject *parent, const QString &name, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
 
void qt_qFindChildren_helper (const QObject *parent, const QString &name, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
 
void qt_qFindChildren_helper (const QObject *parent, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
 
QObjectqt_qFindChild_helper (const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options)
 
const char * qFlagLocation (const char *method)
 
static int extract_code (const char *member)
 
static const char * extract_location (const char *member)
 
static bool check_signal_macro (const QObject *sender, const char *signal, const char *func, const char *op)
 
static bool check_method_code (int code, const QObject *object, const char *method, const char *func)
 
static Q_DECL_COLD_FUNCTION void err_method_notfound (const QObject *object, const char *method, const char *func)
 
static Q_DECL_COLD_FUNCTION void err_info_about_objects (const char *func, const QObject *sender, const QObject *receiver)
 
static void check_and_warn_compat (const QMetaObject *sender, const QMetaMethod &signal, const QMetaObject *receiver, const QMetaMethod &method)
 
static int methodIndexToSignalIndex (const QMetaObject **base, int signal_index)
 
static QByteArray formatConnectionSignature (const char *className, const QMetaMethod &method)
 
static QByteArray msgConnect (const QMetaObject *senderMo, const QByteArray &senderName, const QMetaMethod &signal, const QObject *receiver, int receiverIndex)
 
static void queued_activate (QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv)
 
template<bool callbacks_enabled>
void doActivate (QObject *sender, int signal_index, void **argv)
 
static void dumpRecursive (int level, const QObject *object)
 
QDebug operator<< (QDebug dbg, const QObject *o)
 
void qDeleteInEventHandler (QObject *o)
 
static void connectWarning (const QObject *sender, const QMetaObject *senderMetaObject, const QObject *receiver, const char *message)
 

Variables

static int DIRECT_CONNECTION_ONLY = 0
 
Q_CORE_EXPORT QBasicAtomicPointer< QSignalSpyCallbackSetqt_signal_spy_callback_set = Q_BASIC_ATOMIC_INITIALIZER(nullptr)
 
static Q_CONSTINIT QBasicMutex _q_ObjectMutexPool [131]
 

Function Documentation

◆ check_and_warn_compat()

static void check_and_warn_compat ( const QMetaObject sender,
const QMetaMethod signal,
const QMetaObject receiver,
const QMetaMethod method 
)
inlinestatic

Definition at line 2736 of file qobject.cpp.

References QMetaObject::className(), QMetaMethod::Compatibility, method, qCWarning, QMetaMethod::Signal, and signal.

Referenced by QObject::connect(), and QObject::connect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_method_code()

static bool check_method_code ( int  code,
const QObject object,
const char *  method,
const char *  func 
)
static

Definition at line 2458 of file qobject.cpp.

References method, qCWarning, QSIGNAL_CODE, and QSLOT_CODE.

Referenced by QObject::connect(), and QObject::disconnect().

+ Here is the caller graph for this function:

◆ check_parent_thread()

static bool check_parent_thread ( QObject parent,
QThreadData parentThreadData,
QThreadData currentThreadData 
)
static

Definition at line 875 of file qobject.cpp.

References QBasicAtomicPointer< X >::loadAcquire(), parent, qWarning, and QThreadData::thread.

Referenced by QObject::QObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_signal_macro()

static bool check_signal_macro ( const QObject sender,
const char *  signal,
const char *  func,
const char *  op 
)
static

Definition at line 2442 of file qobject.cpp.

References extract_code(), qCWarning, QSIGNAL_CODE, QSLOT_CODE, and signal.

Referenced by QObject::connect(), QObject::disconnect(), and QObject::receivers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeOffsets()

static void computeOffsets ( const QMetaObject metaobject,
int *  signalOffset,
int *  methodOffset 
)
static

For a given metaobject, compute the signal offset, and the method offset (including signals)

Definition at line 216 of file qobject.cpp.

References d, QMetaObject::d, QMetaObjectPrivate::get(), Q_ASSERT, and QMetaObject::Data::superdata.

Referenced by QMetaObjectPrivate::memberIndexes(), and methodIndexToSignalIndex().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ connectWarning()

static void connectWarning ( const QObject sender,
const QMetaObject senderMetaObject,
const QObject receiver,
const char *  message 
)
static

Definition at line 5070 of file qobject.cpp.

References QMetaObject::className(), and qCWarning.

Referenced by QObjectPrivate::connectImpl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doActivate()

◆ dumpRecursive()

static void dumpRecursive ( int  level,
const QObject object 
)
static

Definition at line 4233 of file qobject.cpp.

References child, dumpRecursive(), QObjectPrivate::flagsForDumping(), QObjectPrivate::get(), qDebug, and qUtf16Printable.

Referenced by QObject::dumpObjectTree(), and dumpRecursive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ err_info_about_objects()

static Q_DECL_COLD_FUNCTION void err_info_about_objects ( const char *  func,
const QObject sender,
const QObject receiver 
)
static

Definition at line 2489 of file qobject.cpp.

References QObject::objectName, and qCWarning.

Referenced by QObject::connect(), and QObject::disconnect().

+ Here is the caller graph for this function:

◆ err_method_notfound()

static Q_DECL_COLD_FUNCTION void err_method_notfound ( const QObject object,
const char *  method,
const char *  func 
)
static

Definition at line 2471 of file qobject.cpp.

References extract_code(), extract_location(), method, qCWarning, QSIGNAL_CODE, and QSLOT_CODE.

Referenced by QObject::connect(), QObject::disconnect(), and QObject::receivers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract_code()

static int extract_code ( const char *  member)
static

Definition at line 2425 of file qobject.cpp.

Referenced by check_signal_macro(), QObject::connect(), QObject::disconnect(), and err_method_notfound().

+ Here is the caller graph for this function:

◆ extract_location()

static const char * extract_location ( const char *  member)
static

Definition at line 2431 of file qobject.cpp.

References qstrlen().

Referenced by err_method_notfound().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatConnectionSignature()

static QByteArray formatConnectionSignature ( const char *  className,
const QMetaMethod method 
)
static

Definition at line 3621 of file qobject.cpp.

References className, method, Q_ASSERT, and QByteArrayLiteral.

Referenced by msgConnect().

+ Here is the caller graph for this function:

◆ methodIndexToSignalIndex()

static int methodIndexToSignalIndex ( const QMetaObject **  base,
int  signal_index 
)
static

Definition at line 3391 of file qobject.cpp.

References base, computeOffsets(), QObjectData::metaObject, and QMetaObjectPrivate::originalClone().

Referenced by QMetaObject::connect(), QObjectPrivate::connect(), QMetaObject::disconnect(), QObjectPrivate::disconnect(), QMetaObject::disconnectOne(), and QObjectPrivate::getPropertyAdaptorSlotObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgConnect()

static QByteArray msgConnect ( const QMetaObject senderMo,
const QByteArray senderName,
const QMetaMethod signal,
const QObject receiver,
int  receiverIndex 
)
static

Definition at line 3639 of file qobject.cpp.

References QMetaObject::className(), formatConnectionSignature(), QObject::objectName, QByteArrayLiteral, signal, and QString::toLatin1().

Referenced by QMetaObject::connectSlotsByName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<()

QDebug operator<< ( QDebug  dbg,
const QObject o 
)

Definition at line 4336 of file qobject.cpp.

References o.

◆ Q_TRACE_POINT() [1/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_declarative_signal_entry  ,
QObject sender,
int  signalIndex 
)

◆ Q_TRACE_POINT() [2/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_declarative_signal_exit   
)

◆ Q_TRACE_POINT() [3/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_entry  ,
QObject sender,
int  signalIndex 
)

◆ Q_TRACE_POINT() [4/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_exit   
)

◆ Q_TRACE_POINT() [5/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_slot_entry  ,
QObject receiver,
int  slotIndex 
)

◆ Q_TRACE_POINT() [6/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_slot_exit   
)

◆ Q_TRACE_POINT() [7/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_slot_functor_entry  ,
void slotObject 
)

◆ Q_TRACE_POINT() [8/10]

Q_TRACE_POINT ( qtcore  ,
QMetaObject_activate_slot_functor_exit   
)

◆ Q_TRACE_POINT() [9/10]

QT_BEGIN_NAMESPACE Q_TRACE_POINT ( qtcore  ,
QObject_ctor  ,
QObject object 
)

◆ Q_TRACE_POINT() [10/10]

Q_TRACE_POINT ( qtcore  ,
QObject_dtor  ,
QObject object 
)

◆ qDeleteInEventHandler()

void qDeleteInEventHandler ( QObject o)

Definition at line 4876 of file qobject.cpp.

References o.

Referenced by QStatusBar::clearMessage(), QNativeSocketEngine::close(), QObject::event(), QWhatsThis::hideText(), and QSingleShotTimer::timerEvent().

+ Here is the caller graph for this function:

◆ qFlagLocation()

const char * qFlagLocation ( const char *  method)

Definition at line 2419 of file qobject.cpp.

References method.

◆ qt_qFindChild_helper()

QObject * qt_qFindChild_helper ( const QObject parent,
const QString name,
const QMetaObject mo,
Qt::FindChildOptions  options 
)

Definition at line 2121 of file qobject.cpp.

References child, QObject::children(), Qt::FindChildrenRecursively, mo, QObjectData::parent, Q_ASSERT, and qt_qFindChild_helper().

Referenced by QObject::findChild(), and qt_qFindChild_helper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_qFindChildren_helper() [1/2]

void qt_qFindChildren_helper ( const QObject parent,
const QMetaObject mo,
QList< void * > *  list,
Qt::FindChildOptions  options 
)

Definition at line 2084 of file qobject.cpp.

References QList< T >::append(), QObject::children(), Qt::FindChildrenRecursively, list, mo, QObjectData::parent, Q_ASSERT, and qt_qFindChildren_helper().

+ Here is the call graph for this function:

◆ qt_qFindChildren_helper() [2/2]

void qt_qFindChildren_helper ( const QObject parent,
const QString name,
const QMetaObject mo,
QList< void * > *  list,
Qt::FindChildOptions  options 
)

Definition at line 2072 of file qobject.cpp.

References list, mo, QObjectData::parent, qt_qFindChildren_helper(), and qt_qFindChildren_with_name().

Referenced by QObject::findChildren(), QObject::findChildren(), qt_qFindChildren_helper(), and qt_qFindChildren_helper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_qFindChildren_with_name()

static void qt_qFindChildren_with_name ( const QObject parent,
const QString name,
const QMetaObject mo,
QList< void * > *  list,
Qt::FindChildOptions  options 
)
static

Definition at line 2054 of file qobject.cpp.

References QList< T >::append(), QObject::children(), Qt::FindChildrenRecursively, list, mo, QObjectData::parent, Q_ASSERT, and qt_qFindChildren_with_name().

Referenced by qt_qFindChildren_helper(), and qt_qFindChildren_with_name().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_register_signal_spy_callbacks()

void qt_register_signal_spy_callbacks ( QSignalSpyCallbackSet callback_set)

Definition at line 64 of file qobject.cpp.

References qt_signal_spy_callback_set.

Referenced by QSignalDumper::endDump(), and QSignalDumper::startDump().

+ Here is the caller graph for this function:

◆ queued_activate()

static void queued_activate ( QObject sender,
int  signal,
QObjectPrivate::Connection c,
void **  argv 
)
static

signal must be in the signal index range (see QObjectPrivate::signalIndex()).

Definition at line 3792 of file qobject.cpp.

References QMetaCallEvent::args(), args, create(), DIRECT_CONNECTION_ONLY, QCoreApplication::postEvent(), queuedConnectionTypes(), QMutexLocker< Mutex >::relock(), QObjectPrivate::removeConnection(), QMetaObjectPrivate::signal(), signal, signalSlotLock(), QMetaCallEvent::types(), and QMutexLocker< Mutex >::unlock().

Referenced by doActivate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queuedConnectionTypes() [1/2]

static int * queuedConnectionTypes ( const QArgumentType argumentTypes,
int  argc 
)
static

Definition at line 105 of file qobject.cpp.

References QMetaType::fromName(), i, QMetaType::id(), qCWarning, and QArgumentType::type().

+ Here is the call graph for this function:

◆ queuedConnectionTypes() [2/2]

static int * queuedConnectionTypes ( const QMetaMethod method)
static

Definition at line 77 of file qobject.cpp.

References QMetaType::flags(), i, QMetaType::id(), QMetaType::IsPointer, method, Q_CHECK_PTR(), qCWarning, and typeName.

Referenced by QObject::connect(), QObject::connect(), and queued_activate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ signalSlotLock()

static QBasicMutex * signalSlotLock ( const QObject o)
inlinestatic

Variable Documentation

◆ _q_ObjectMutexPool

Q_CONSTINIT QBasicMutex _q_ObjectMutexPool[131]
static

Definition at line 130 of file qobject.cpp.

Referenced by signalSlotLock().

◆ DIRECT_CONNECTION_ONLY

int DIRECT_CONNECTION_ONLY = 0
static

Definition at line 57 of file qobject.cpp.

Referenced by QObjectPrivate::Connection::~Connection(), and queued_activate().

◆ qt_signal_spy_callback_set