Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qobject.cpp File Reference

(1e0b940256e2f7f63159ebe6420fc778a3d43b4f)

#include <QtCore/qtconfigmacros.h>
#include "qobject.h"
#include "qobject_p.h"
#include "qobject_p_p.h"
#include "qmetaobject_p.h"
#include <QtCore/private/qtclasshelper_p.h>
#include <QtCore/qspan.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 <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 <optional>
#include <iterator>
#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

Enumerations

enum class  ConnectionEnd : bool { Sender , Receiver , Sender , Receiver }
enum class  ConnectionEnd : bool { Sender , Receiver , Sender , Receiver }

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 (QSpan< const QArgumentType > argumentTypes)
static QBasicMutexsignalSlotLock (const QObject *o)
static void disconnectNotifySender (QObject *sender, int signalIndex, Qt::HANDLE currentThreadId)
static void computeOffsets (const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
static bool check_parent_thread (QObject *parent, QThreadData *parentThreadData, QThreadData *currentThreadData)
static bool matches_objectName_non_null (QObject *obj, QAnyStringView name)
void qt_qFindChildren_helper (const QObject *parent, QAnyStringView name, const QMetaObject &mo, QList< void * > *list, Qt::FindChildOptions options)
QObjectqt_qFindChild_helper (const QObject *parent, QAnyStringView 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_object (const char *func, const QObject *o, ConnectionEnd end)
static Q_DECL_COLD_FUNCTION void err_info_about_objects (const char *func, const QObject *sender, const QObject *receiver)
static Q_DECL_COLD_FUNCTION void connectWarning (const QObject *sender, const QMetaObject *senderMetaObject, const QObject *receiver, const char *message)
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)

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]

Enumeration Type Documentation

◆ ConnectionEnd [1/2]

enum class ConnectionEnd : bool
strong
Enumerator
Sender 
Receiver 
Sender 
Receiver 

Definition at line 2781 of file qobject.cpp.

◆ ConnectionEnd [2/2]

enum class ConnectionEnd : bool
strong
Enumerator
Sender 
Receiver 
Sender 
Receiver 

Definition at line 2781 of file qobject.cpp.

Function Documentation

◆ check_and_warn_compat()

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

Definition at line 3066 of file qobject.cpp.

◆ check_method_code()

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

Definition at line 2734 of file qobject.cpp.

◆ check_parent_thread()

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

Definition at line 972 of file qobject.cpp.

◆ check_signal_macro()

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

Definition at line 2718 of file qobject.cpp.

References extract_code().

Here is the call graph for this function:

◆ computeOffsets()

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 251 of file qobject.cpp.

References QMetaObjectPrivate::methodCount, QMetaObjectPrivate::revision, and QMetaObjectPrivate::signalCount.

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

Here is the caller graph for this function:

◆ connectWarning()

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

Definition at line 2807 of file qobject.cpp.

◆ disconnectNotifySender()

void disconnectNotifySender ( QObject * sender,
int signalIndex,
Qt::HANDLE currentThreadId )
static

Tells sender that the connection for signalIndex is gone, because its receiver is being destroyed.

The caller holds the receiver's signalSlotLock, which sender's destructor must also take to tear down this (still-present) connection. So sender cannot get past ~QObject(), and reading its QObjectPrivate here is safe. That lock does not, however, hold back sender's further-derived destructors: those run before ~QObject() takes any lock, and rewrite the vptr as they go. Resolving the signal and calling disconnectNotify() are therefore virtual calls that may only be made from the thread that owns sender. Post them to that thread otherwise, unless it can no longer deliver events (e.g. it has finished), where the event would leak.

Definition at line 166 of file qobject.cpp.

◆ doActivate()

template<bool callbacks_enabled>
void doActivate ( QObject * sender,
int signal_index,
void ** argv )

Definition at line 4346 of file qobject.cpp.

◆ dumpRecursive()

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

Definition at line 4718 of file qobject.cpp.

◆ err_info_about_object()

Q_DECL_COLD_FUNCTION void err_info_about_object ( const char * func,
const QObject * o,
ConnectionEnd end )
static

Definition at line 2783 of file qobject.cpp.

References Sender.

Referenced by err_info_about_objects().

Here is the caller graph for this function:

◆ err_info_about_objects()

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

Definition at line 2800 of file qobject.cpp.

References err_info_about_object(), Receiver, and Sender.

Here is the call graph for this function:

◆ err_method_notfound()

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

Definition at line 2763 of file qobject.cpp.

References extract_code(), and extract_location().

Here is the call graph for this function:

◆ extract_code()

int extract_code ( const char * member)
static

Definition at line 2701 of file qobject.cpp.

Referenced by check_signal_macro(), and err_method_notfound().

Here is the caller graph for this function:

◆ extract_location()

const char * extract_location ( const char * member)
static

Definition at line 2707 of file qobject.cpp.

Referenced by err_method_notfound().

Here is the caller graph for this function:

◆ formatConnectionSignature()

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

Definition at line 4023 of file qobject.cpp.

◆ matches_objectName_non_null()

bool matches_objectName_non_null ( QObject * obj,
QAnyStringView name )
static

Definition at line 2241 of file qobject.cpp.

◆ methodIndexToSignalIndex()

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

Definition at line 3767 of file qobject.cpp.

References computeOffsets().

Here is the call graph for this function:

◆ msgConnect()

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

Definition at line 4041 of file qobject.cpp.

◆ operator<<()

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

Definition at line 4830 of file qobject.cpp.

◆ 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 )

◆ qFlagLocation()

const char * qFlagLocation ( const char * method)

Definition at line 2695 of file qobject.cpp.

◆ qt_qFindChild_helper()

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

Definition at line 2288 of file qobject.cpp.

◆ qt_qFindChildren_helper()

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

Definition at line 2251 of file qobject.cpp.

◆ qt_register_signal_spy_callbacks()

void qt_register_signal_spy_callbacks ( QSignalSpyCallbackSet * callback_set)

Definition at line 74 of file qobject.cpp.

◆ queued_activate()

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 4288 of file qobject.cpp.

◆ queuedConnectionTypes() [1/2]

int * queuedConnectionTypes ( const QMetaMethod & method)
static

Definition at line 87 of file qobject.cpp.

◆ queuedConnectionTypes() [2/2]

int * queuedConnectionTypes ( QSpan< const QArgumentType > argumentTypes)
static

Definition at line 116 of file qobject.cpp.

◆ signalSlotLock()

QBasicMutex * signalSlotLock ( const QObject * o)
inlinestatic

mutex to be locked when accessing the connection lists or the senders list

Definition at line 148 of file qobject.cpp.

Variable Documentation

◆ _q_ObjectMutexPool

Q_CONSTINIT QBasicMutex _q_ObjectMutexPool
static

Definition at line 142 of file qobject.cpp.

◆ DIRECT_CONNECTION_ONLY

int DIRECT_CONNECTION_ONLY = 0
static

Definition at line 67 of file qobject.cpp.

◆ qt_signal_spy_callback_set

Q_CORE_EXPORT QBasicAtomicPointer<QSignalSpyCallbackSet> qt_signal_spy_callback_set = Q_BASIC_ATOMIC_INITIALIZER(nullptr)

Definition at line 72 of file qobject.cpp.