Qt 4.8
Classes | Typedefs | Functions | Variables
qobject.cpp File Reference
#include "qobject.h"
#include "qobject_p.h"
#include "qmetaobject_p.h"
#include "qabstracteventdispatcher.h"
#include "qcoreapplication.h"
#include "qcoreapplication_p.h"
#include "qvariant.h"
#include "qmetaobject.h"
#include <qregexp.h>
#include <qthread.h>
#include <private/qthread_p.h>
#include <qdebug.h>
#include <qhash.h>
#include <qpair.h>
#include <qset.h>
#include <qsemaphore.h>
#include <qsharedpointer.h>
#include <private/qorderedmutexlocker_p.h>
#include <private/qmutexpool_p.h>
#include <new>
#include <ctype.h>
#include <limits.h>
#include "moc_qobject.cpp"

Go to the source code of this file.

Classes

class  QObjectConnectionListVector
 

Typedefs

typedef QMultiHash< QObject *, QObject ** > GuardHash
 

Functions

static void check_and_warn_compat (const QMetaObject *sender, const QMetaMethod &signal, const QMetaObject *receiver, const QMetaMethod &method)
 
static bool check_method_code (int code, const QObject *object, const char *method, const char *func)
 
static bool check_parent_thread (QObject *parent, QThreadData *parentThreadData, QThreadData *currentThreadData)
 
static bool check_signal_macro (const QObject *sender, const char *signal, const char *func, const char *op)
 
static void computeOffsets (const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
 
static void dumpRecursive (int level, QObject *object)
 
static void err_info_about_objects (const char *func, const QObject *sender, const QObject *receiver)
 
static void err_method_notfound (const QObject *object, const char *method, const char *func)
 
static int extract_code (const char *member)
 
static const char * extract_location (const char *member)
 
static int methodIndexToSignalIndex (const QMetaObject *metaObject, int signal_index)
 
QDebug operator<< (QDebug dbg, const QObject *o)
 
void qDeleteInEventHandler (QObject *o)
 
const char * qFlagLocation (const char *method)
 
Q_CORE_EXPORT void qt_addObject (QObject *)
 
QObjectqt_qFindChild_helper (const QObject *parent, const QString &name, const QMetaObject &mo)
 
void qt_qFindChildren_helper (const QObject *parent, const QString &name, const QRegExp *re, const QMetaObject &mo, QList< void *> *list)
 
Q_CORE_EXPORT void qt_removeObject (QObject *)
 
static void queued_activate (QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv)
 
static int * queuedConnectionTypes (const QList< QByteArray > &typeNames)
 
static QMutexsignalSlotLock (const QObject *o)
 

Variables

static int DIRECT_CONNECTION_ONLY = 0
 
static QBasicAtomicInt objectCount = Q_BASIC_ATOMIC_INITIALIZER(0)
 
static QBasicAtomicPointer< QMutexPoolsignalSlotMutexes = Q_BASIC_ATOMIC_INITIALIZER(0)
 

Typedef Documentation

◆ GuardHash

Definition at line 384 of file qobject.cpp.

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

Referenced by QObject::connect().

2499 {
2500  if (signal.attributes() & QMetaMethod::Compatibility) {
2501  if (!(method.attributes() & QMetaMethod::Compatibility))
2502  qWarning("QObject::connect: Connecting from COMPAT signal (%s::%s)",
2503  sender->className(), signal.signature());
2504  } else if ((method.attributes() & QMetaMethod::Compatibility) &&
2505  method.methodType() == QMetaMethod::Signal) {
2506  qWarning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
2507  sender->className(), signal.signature(),
2508  receiver->className(), method.signature());
2509  }
2510 }
Q_CORE_EXPORT void qWarning(const char *,...)
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
int attributes() const
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).

◆ check_method_code()

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

Definition at line 2261 of file qobject.cpp.

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

2263 {
2264  if (code != QSLOT_CODE && code != QSIGNAL_CODE) {
2265  qWarning("Object::%s: Use the SLOT or SIGNAL macro to "
2266  "%s %s::%s", func, func, object->metaObject()->className(), method);
2267  return false;
2268  }
2269  return true;
2270 }
Q_CORE_EXPORT void qWarning(const char *,...)
#define QSIGNAL_CODE
Definition: qobjectdefs.h:244
#define QSLOT_CODE
Definition: qobjectdefs.h:243
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ check_parent_thread()

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

Definition at line 718 of file qobject.cpp.

Referenced by QObject::QObject().

721 {
722  if (parent && parentThreadData != currentThreadData) {
723  QThread *parentThread = parentThreadData->thread;
724  QThread *currentThread = currentThreadData->thread;
725  qWarning("QObject: Cannot create children for a parent that is in a different thread.\n"
726  "(Parent is %s(%p), parent's thread is %s(%p), current thread is %s(%p)",
727  parent->metaObject()->className(),
728  parent,
729  parentThread ? parentThread->metaObject()->className() : "QThread",
730  parentThread,
731  currentThread ? currentThread->metaObject()->className() : "QThread",
732  currentThread);
733  return false;
734  }
735  return true;
736 }
Q_CORE_EXPORT void qWarning(const char *,...)
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QThread * thread
Definition: qthread_p.h:260
The QThread class provides a platform-independent way to manage threads.
Definition: qthread.h:59
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ check_signal_macro()

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

Definition at line 2245 of file qobject.cpp.

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

2247 {
2248  int sigcode = extract_code(signal);
2249  if (sigcode != QSIGNAL_CODE) {
2250  if (sigcode == QSLOT_CODE)
2251  qWarning("Object::%s: Attempt to %s non-signal %s::%s",
2252  func, op, sender->metaObject()->className(), signal+1);
2253  else
2254  qWarning("Object::%s: Use the SIGNAL macro to %s %s::%s",
2255  func, op, sender->metaObject()->className(), signal);
2256  return false;
2257  }
2258  return true;
2259 }
Q_CORE_EXPORT void qWarning(const char *,...)
#define QSIGNAL_CODE
Definition: qobjectdefs.h:244
#define QSLOT_CODE
Definition: qobjectdefs.h:243
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
static int extract_code(const char *member)
Definition: qobject.cpp:2228
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ computeOffsets()

static void computeOffsets ( const QMetaObject metaobject,
int *  signalOffset,
int *  methodOffset 
)
static
Warning
This function is not part of the public interface. For a given metaobject, compute the signal offset, and the method offset (including signals)

Definition at line 225 of file qobject.cpp.

Referenced by QMetaObject::activate(), QObject::connect(), QMetaObject::connectSlotsByName(), QObject::disconnect(), QObject::dumpObjectInfo(), QMetaObjectPrivate::memberIndexes(), methodIndexToSignalIndex(), and QObjectPrivate::signalIndex().

226 {
227  *signalOffset = *methodOffset = 0;
228  const QMetaObject *m = metaobject->d.superdata;
229  while (m) {
231  *methodOffset += d->methodCount;
232  *signalOffset += (d->revision >= 4) ? d->signalCount : d->methodCount;
233  /*Before Qt 4.6 (revision 4), the signalCount information was not generated by moc.
234  so for compatibility we consider all the method as slot for old moc output*/
235  m = m->d.superdata;
236  }
237 }
double d
Definition: qnumeric_p.h:62
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
const QMetaObject * superdata
Definition: qobjectdefs.h:469
struct QMetaObject::@38 d
static const QMetaObjectPrivate * get(const QMetaObject *metaobject)

◆ dumpRecursive()

static void dumpRecursive ( int  level,
QObject object 
)
static

Definition at line 3854 of file qobject.cpp.

Referenced by QObject::dumpObjectTree().

3855 {
3856 #if defined(QT_DEBUG)
3857  if (object) {
3858  QByteArray buf;
3859  buf.fill(' ', level / 2 * 8);
3860  if (level % 2)
3861  buf += " ";
3862  QString name = object->objectName();
3863  QString flags = QLatin1String("");
3864 #if 0
3865  if (qApp->focusWidget() == object)
3866  flags += 'F';
3867  if (object->isWidgetType()) {
3868  QWidget * w = (QWidget *)object;
3869  if (w->isVisible()) {
3870  QString t("<%1,%2,%3,%4>");
3871  flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height());
3872  } else {
3873  flags += 'I';
3874  }
3875  }
3876 #endif
3877  qDebug("%s%s::%s %s", (const char*)buf, object->metaObject()->className(), name.toLocal8Bit().data(),
3878  flags.toLatin1().data());
3879  QObjectList children = object->children();
3880  if (!children.isEmpty()) {
3881  for (int i = 0; i < children.size(); ++i)
3882  dumpRecursive(level+1, children.at(i));
3883  }
3884  }
3885 #else
3886  Q_UNUSED(level)
3887  Q_UNUSED(object)
3888 #endif
3889 }
QByteArray & fill(char c, int size=-1)
Sets every byte in the byte array to character ch.
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
bool isVisible() const
Definition: qwidget.h:1005
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void dumpRecursive(int level, QObject *object)
Definition: qobject.cpp:3854
The QString class provides a Unicode character string.
Definition: qstring.h:83
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
Q_CORE_EXPORT void qDebug(const char *,...)
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
#define qApp
const char * name
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ err_info_about_objects()

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

Definition at line 2293 of file qobject.cpp.

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

2296 {
2297  QString a = sender ? sender->objectName() : QString();
2298  QString b = receiver ? receiver->objectName() : QString();
2299  if (!a.isEmpty())
2300  qWarning("Object::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
2301  if (!b.isEmpty())
2302  qWarning("Object::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
2303 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QString objectName
the name of this object
Definition: qobject.h:114
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049

◆ err_method_notfound()

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

Definition at line 2272 of file qobject.cpp.

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

2274 {
2275  const char *type = "method";
2276  switch (extract_code(method)) {
2277  case QSLOT_CODE: type = "slot"; break;
2278  case QSIGNAL_CODE: type = "signal"; break;
2279  }
2280  const char *loc = extract_location(method);
2281  if (strchr(method,')') == 0) // common typing mistake
2282  qWarning("Object::%s: Parentheses expected, %s %s::%s%s%s",
2283  func, type, object->metaObject()->className(), method+1,
2284  loc ? " in ": "", loc ? loc : "");
2285  else
2286  qWarning("Object::%s: No such %s %s::%s%s%s",
2287  func, type, object->metaObject()->className(), method+1,
2288  loc ? " in ": "", loc ? loc : "");
2289 
2290 }
int type
Definition: qmetatype.cpp:239
static const char * extract_location(const char *member)
Definition: qobject.cpp:2234
Q_CORE_EXPORT void qWarning(const char *,...)
#define QSIGNAL_CODE
Definition: qobjectdefs.h:244
#define QSLOT_CODE
Definition: qobjectdefs.h:243
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
static int extract_code(const char *member)
Definition: qobject.cpp:2228
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ extract_code()

static int extract_code ( const char *  member)
static

Definition at line 2228 of file qobject.cpp.

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

2229 {
2230  // extract code, ensure QMETHOD_CODE <= code <= QSIGNAL_CODE
2231  return (((int)(*member) - '0') & 0x3);
2232 }

◆ extract_location()

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

Definition at line 2234 of file qobject.cpp.

Referenced by err_method_notfound().

2235 {
2236  if (QThreadData::current()->flaggedSignatures.contains(member)) {
2237  // signature includes location information after the first null-terminator
2238  const char *location = member + qstrlen(member) + 1;
2239  if (*location != '\0')
2240  return location;
2241  }
2242  return 0;
2243 }
uint qstrlen(const char *str)
Definition: qbytearray.h:79
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
static QThreadData * current()

◆ methodIndexToSignalIndex()

static int methodIndexToSignalIndex ( const QMetaObject metaObject,
int  signal_index 
)
static

Definition at line 3169 of file qobject.cpp.

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

3170 {
3171  if (signal_index < 0)
3172  return signal_index;
3173  while (metaObject && metaObject->methodOffset() > signal_index)
3174  metaObject = metaObject->superClass();
3175 
3176  if (metaObject) {
3177  int signalOffset, methodOffset;
3178  computeOffsets(metaObject, &signalOffset, &methodOffset);
3179  if (signal_index < metaObject->methodCount())
3180  signal_index = QMetaObjectPrivate::originalClone(metaObject, signal_index - methodOffset) + signalOffset;
3181  else
3182  signal_index = signal_index - methodOffset + signalOffset;
3183  }
3184  return signal_index;
3185 }
static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
Definition: qobject.cpp:225
int methodOffset() const
Returns the method offset for this class; i.e.
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
static int originalClone(const QMetaObject *obj, int local_method_index)

◆ operator<<()

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

Definition at line 4030 of file qobject.cpp.

4030  {
4031 #ifndef Q_BROKEN_DEBUG_STREAM
4032  if (!o)
4033  return dbg << "QObject(0x0) ";
4034  dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
4035  if (!o->objectName().isEmpty())
4036  dbg << ", name = " << o->objectName();
4037  dbg << ')';
4038  return dbg.space();
4039 #else
4040  qWarning("This compiler doesn't support streaming QObject to QDebug");
4041  return dbg;
4042  Q_UNUSED(o);
4043 #endif
4044 }
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
QString objectName
the name of this object
Definition: qobject.h:114
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Q_CORE_EXPORT void qWarning(const char *,...)
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ qDeleteInEventHandler()

void qDeleteInEventHandler ( QObject o)

Definition at line 4348 of file qobject.cpp.

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

4349 {
4350 #ifdef QT_JAMBI_BUILD
4351  if (!o)
4352  return;
4353  QObjectPrivate::get(o)->inEventHandler = false;
4354 #endif
4355  delete o;
4356 }
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
uint inEventHandler
Definition: qobject.h:102

◆ qFlagLocation()

const char* qFlagLocation ( const char *  method)

Definition at line 2222 of file qobject.cpp.

2223 {
2225  return method;
2226 }
FlaggedDebugSignatures flaggedSignatures
Definition: qthread_p.h:275
void store(const char *method)
Definition: qthread_p.h:248
static QThreadData * current()

◆ qt_addObject()

Q_CORE_EXPORT void qt_addObject ( QObject )

Definition at line 114 of file qobject.cpp.

Referenced by QObject::QObject().

115 {
116  objectCount.ref();
117 }
static QBasicAtomicInt objectCount
Definition: qobject.cpp:98

◆ qt_qFindChild_helper()

QObject* qt_qFindChild_helper ( const QObject parent,
const QString name,
const QMetaObject mo 
)
Warning
This function is not part of the public interface.

Definition at line 1924 of file qobject.cpp.

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

1925 {
1926  if (!parent)
1927  return 0;
1928  const QObjectList &children = parent->children();
1929  QObject *obj;
1930  int i;
1931  for (i = 0; i < children.size(); ++i) {
1932  obj = children.at(i);
1933  if (mo.cast(obj) && (name.isNull() || obj->objectName() == name))
1934  return obj;
1935  }
1936  for (i = 0; i < children.size(); ++i) {
1937  obj = qt_qFindChild_helper(children.at(i), name, mo);
1938  if (obj)
1939  return obj;
1940  }
1941  return 0;
1942 }
QString objectName
the name of this object
Definition: qobject.h:114
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObject * cast(QObject *obj) const
Returns obj if object obj inherits from this meta-object; otherwise returns 0.
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
QObject * qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo)
Definition: qobject.cpp:1924

◆ qt_qFindChildren_helper()

void qt_qFindChildren_helper ( const QObject parent,
const QString name,
const QRegExp re,
const QMetaObject mo,
QList< void *> *  list 
)
Warning
This function is not part of the public interface.

Definition at line 1900 of file qobject.cpp.

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

1902 {
1903  if (!parent || !list)
1904  return;
1905  const QObjectList &children = parent->children();
1906  QObject *obj;
1907  for (int i = 0; i < children.size(); ++i) {
1908  obj = children.at(i);
1909  if (mo.cast(obj)) {
1910  if (re) {
1911  if (re->indexIn(obj->objectName()) != -1)
1912  list->append(obj);
1913  } else {
1914  if (name.isNull() || obj->objectName() == name)
1915  list->append(obj);
1916  }
1917  }
1918  qt_qFindChildren_helper(obj, name, re, mo, list);
1919  }
1920 }
void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, const QMetaObject &mo, QList< void *> *list)
Definition: qobject.cpp:1900
QString objectName
the name of this object
Definition: qobject.h:114
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObject * cast(QObject *obj) const
Returns obj if object obj inherits from this meta-object; otherwise returns 0.
int indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
Attempts to find a match in str from position offset (0 by default).
Definition: qregexp.cpp:4136
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197

◆ qt_removeObject()

Q_CORE_EXPORT void qt_removeObject ( QObject )

Definition at line 119 of file qobject.cpp.

Referenced by QObject::~QObject().

120 {
121  if(!objectCount.deref()) {
122  QMutexPool *old = signalSlotMutexes.fetchAndStoreAcquire(0);
123  delete old;
124  }
125 }
static QBasicAtomicInt objectCount
Definition: qobject.cpp:98
static QBasicAtomicPointer< QMutexPool > signalSlotMutexes
Definition: qobject.cpp:97
The QMutexPool class provides a pool of QMutex objects.
Definition: qmutexpool_p.h:64

◆ queued_activate()

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

Definition at line 3459 of file qobject.cpp.

Referenced by QMetaObject::activate().

3460 {
3462  QMetaMethod m = sender->metaObject()->method(signal);
3463  int *tmp = queuedConnectionTypes(m.parameterTypes());
3464  if (!tmp) // cannot queue arguments
3465  tmp = &DIRECT_CONNECTION_ONLY;
3466  if (!c->argumentTypes.testAndSetOrdered(0, tmp)) {
3467  if (tmp != &DIRECT_CONNECTION_ONLY)
3468  delete [] tmp;
3469  }
3470  }
3471  if (c->argumentTypes == &DIRECT_CONNECTION_ONLY) // cannot activate
3472  return;
3473  int nargs = 1; // include return type
3474  while (c->argumentTypes[nargs-1])
3475  ++nargs;
3476  int *types = (int *) qMalloc(nargs*sizeof(int));
3477  Q_CHECK_PTR(types);
3478  void **args = (void **) qMalloc(nargs*sizeof(void *));
3479  Q_CHECK_PTR(args);
3480  types[0] = 0; // return type
3481  args[0] = 0; // return value
3482  for (int n = 1; n < nargs; ++n)
3483  args[n] = QMetaType::construct((types[n] = c->argumentTypes[n-1]), argv[n]);
3485  c->method_relative,
3486  c->callFunction,
3487  sender, signal, nargs,
3488  types, args));
3489 }
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
bool testAndSetOrdered(T *expectedValue, T *newValue)
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
static int DIRECT_CONNECTION_ONLY
Definition: qobject.cpp:71
static void * construct(int type, const void *copy=0)
Returns a copy of copy, assuming it is of type type.
Definition: qmetatype.cpp:1042
QBasicAtomicPointer< int > argumentTypes
Definition: qobject_p.h:124
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
QList< QByteArray > parameterTypes() const
Returns a list of parameter types.
static const struct @32 types[]
static int * queuedConnectionTypes(const QList< QByteArray > &typeNames)
Definition: qobject.cpp:73
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
StaticMetaCallFunction callFunction
Definition: qobject_p.h:118
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ queuedConnectionTypes()

static int* queuedConnectionTypes ( const QList< QByteArray > &  typeNames)
static

Definition at line 73 of file qobject.cpp.

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

74 {
75  int *types = new int [typeNames.count() + 1];
76  Q_CHECK_PTR(types);
77  for (int i = 0; i < typeNames.count(); ++i) {
78  const QByteArray typeName = typeNames.at(i);
79  if (typeName.endsWith('*'))
80  types[i] = QMetaType::VoidStar;
81  else
82  types[i] = QMetaType::type(typeName);
83 
84  if (!types[i]) {
85  qWarning("QObject::connect: Cannot queue arguments of type '%s'\n"
86  "(Make sure '%s' is registered using qRegisterMetaType().)",
87  typeName.constData(), typeName.constData());
88  delete [] types;
89  return 0;
90  }
91  }
92  types[typeNames.count()] = 0;
93 
94  return types;
95 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const char * typeName
Definition: qmetatype.cpp:239
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
static const struct @32 types[]
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ signalSlotLock()

static QMutex* signalSlotLock ( const QObject o)
inlinestatic
Warning
This function is not part of the public interface. mutex to be locked when accessing the connectionlists or the senders list

Definition at line 103 of file qobject.cpp.

Referenced by QMetaObject::activate(), QMetaObjectPrivate::connect(), QMetaObjectPrivate::disconnect(), QMetaObjectPrivate::disconnectHelper(), QObject::dumpObjectInfo(), QObjectPrivate::isSender(), QObjectPrivate::receiverList(), QObject::receivers(), QObject::sender(), QObjectPrivate::senderList(), QObject::senderSignalIndex(), and QObject::~QObject().

104 {
105  if (!signalSlotMutexes) {
106  QMutexPool *mp = new QMutexPool;
107  if (!signalSlotMutexes.testAndSetOrdered(0, mp)) {
108  delete mp;
109  }
110  }
111  return signalSlotMutexes->get(o);
112 }
static QBasicAtomicPointer< QMutexPool > signalSlotMutexes
Definition: qobject.cpp:97
The QMutexPool class provides a pool of QMutex objects.
Definition: qmutexpool_p.h:64

Variable Documentation

◆ DIRECT_CONNECTION_ONLY

int DIRECT_CONNECTION_ONLY = 0
static

Definition at line 71 of file qobject.cpp.

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

◆ objectCount

Definition at line 98 of file qobject.cpp.

Referenced by QDeclarativeEngineDebugPrivate::decode().

◆ signalSlotMutexes

Definition at line 97 of file qobject.cpp.