#include "qobject.h"
#include "qobject_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 <qvarlengtharray.h>
#include <qset.h>
#include <new>
#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 | QConnection |
| class | QConnectionList |
| class | QObjectSet |
Typedefs | |
| typedef QMultiHash< QObject *, QObject ** > | GuardHash |
Functions | |
| static int * | queuedConnectionTypes (const QList< QByteArray > &typeNames) |
| Q_DECLARE_TYPEINFO (QConnection, Q_MOVABLE_TYPE) | |
| Q_CORE_EXPORT void | qt_addObject (QObject *object) |
| Q_CORE_EXPORT void | qt_removeObject (QObject *object) |
| Q_CORE_EXPORT QList< QObject * > | qt_allTopLevelWidgets () |
| void | qt_qFindChildren_helper (const QObject *parent, const QString &name, const QRegExp *re, const QMetaObject &mo, QList< void * > *list) |
| QObject * | qt_qFindChild_helper (const QObject *parent, const QString &name, const QMetaObject &mo) |
| 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 void | err_method_notfound (int code, const QObject *object, const char *method, const char *func) |
| static void | err_info_about_objects (const char *func, const QObject *sender, const QObject *receiver) |
| static void | queued_activate (QObject *sender, const QConnection &c, void **argv, int idFrom, int idTo) |
| static void | dumpRecursive (int level, QObject *object) |
| QDebug | operator<< (QDebug dbg, const QObject *o) |
Variables | |
| static int | DIRECT_CONNECTION_ONLY = 0 |
| typedef QMultiHash<QObject *, QObject **> GuardHash |
Definition at line 371 of file qobject.cpp.
| static bool check_method_code | ( | int | code, | |
| const QObject * | object, | |||
| const char * | method, | |||
| const char * | func | |||
| ) | [static] |
Definition at line 2132 of file qobject.cpp.
References object, QSIGNAL_CODE, QSLOT_CODE, and qWarning().
Referenced by QObject::connect(), and QObject::disconnect().
02134 { 02135 if (code != QSLOT_CODE && code != QSIGNAL_CODE) { 02136 qWarning("Object::%s: Use the SLOT or SIGNAL macro to " 02137 "%s %s::%s", func, func, object->metaObject()->className(), method); 02138 return false; 02139 } 02140 return true; 02141 }
Here is the call graph for this function:

| static bool check_signal_macro | ( | const QObject * | sender, | |
| const char * | signal, | |||
| const char * | func, | |||
| const char * | op | |||
| ) | [static] |
Definition at line 2116 of file qobject.cpp.
References int, QSIGNAL_CODE, QSLOT_CODE, and qWarning().
Referenced by QObject::connect(), QObject::disconnect(), and QObject::receivers().
02118 { 02119 int sigcode = (int)(*signal) - '0'; 02120 if (sigcode != QSIGNAL_CODE) { 02121 if (sigcode == QSLOT_CODE) 02122 qWarning("Object::%s: Attempt to %s non-signal %s::%s", 02123 func, op, sender->metaObject()->className(), signal+1); 02124 else 02125 qWarning("Object::%s: Use the SIGNAL macro to %s %s::%s", 02126 func, op, sender->metaObject()->className(), signal); 02127 return false; 02128 } 02129 return true; 02130 }
Here is the call graph for this function:

| static void dumpRecursive | ( | int | level, | |
| QObject * | object | |||
| ) | [static] |
Definition at line 3116 of file qobject.cpp.
References buf, flags, i, name, object, qApp, qDebug(), QObject::QObjectList(), t, and w.
Referenced by QObject::dumpObjectTree().
03117 { 03118 #if defined(QT_DEBUG) 03119 if (object) { 03120 QByteArray buf; 03121 buf.fill('\t', level/2); 03122 if (level % 2) 03123 buf += " "; 03124 QString name = object->objectName(); 03125 QString flags = QLatin1String(""); 03126 #if 0 03127 if (qApp->focusWidget() == object) 03128 flags += 'F'; 03129 if (object->isWidgetType()) { 03130 QWidget * w = (QWidget *)object; 03131 if (w->isVisible()) { 03132 QString t("<%1,%2,%3,%4>"); 03133 flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height()); 03134 } else { 03135 flags += 'I'; 03136 } 03137 } 03138 #endif 03139 qDebug("%s%s::%s %s", (const char*)buf, object->metaObject()->className(), name.toLocal8Bit().data(), 03140 flags.toLatin1().data()); 03141 QObjectList children = object->children(); 03142 if (!children.isEmpty()) { 03143 for (int i = 0; i < children.size(); ++i) 03144 dumpRecursive(level+1, children.at(i)); 03145 } 03146 } 03147 #else 03148 Q_UNUSED(level) 03149 Q_UNUSED(object) 03150 #endif 03151 }
Here is the call graph for this function:

| static void err_info_about_objects | ( | const char * | func, | |
| const QObject * | sender, | |||
| const QObject * | receiver | |||
| ) | [static] |
Definition at line 2160 of file qobject.cpp.
References a, b, QObject::objectName(), and qWarning().
Referenced by QObject::connect(), and QObject::disconnect().
02163 { 02164 QString a = sender ? sender->objectName() : QString(); 02165 QString b = receiver ? receiver->objectName() : QString(); 02166 if (!a.isEmpty()) 02167 qWarning("Object::%s: (sender name: '%s')", func, a.toLocal8Bit().data()); 02168 if (!b.isEmpty()) 02169 qWarning("Object::%s: (receiver name: '%s')", func, b.toLocal8Bit().data()); 02170 }
Here is the call graph for this function:

| static void err_method_notfound | ( | int | code, | |
| const QObject * | object, | |||
| const char * | method, | |||
| const char * | func | |||
| ) | [static] |
Definition at line 2143 of file qobject.cpp.
References object, QSIGNAL_CODE, QSLOT_CODE, qWarning(), and type.
Referenced by QObject::connect(), QObject::disconnect(), and QObject::receivers().
02145 { 02146 const char *type = 0; 02147 switch (code) { 02148 case QSLOT_CODE: type = "slot"; break; 02149 case QSIGNAL_CODE: type = "signal"; break; 02150 } 02151 if (strchr(method,')') == 0) // common typing mistake 02152 qWarning("Object::%s: Parentheses expected, %s %s::%s", 02153 func, type, object->metaObject()->className(), method); 02154 else 02155 qWarning("Object::%s: No such %s %s::%s", 02156 func, type, object->metaObject()->className(), method); 02157 }
Here is the call graph for this function:

Definition at line 3232 of file qobject.cpp.
03232 { 03233 #ifndef Q_BROKEN_DEBUG_STREAM 03234 if (!o) 03235 return dbg << "QObject(0x0) "; 03236 dbg.nospace() << o->metaObject()->className() << "(" << (void *)o; 03237 if (!o->objectName().isEmpty()) 03238 dbg << ", name = " << o->objectName(); 03239 dbg << ')'; 03240 return dbg.space(); 03241 #else 03242 qWarning("This compiler doesn't support streaming QObject to QDebug"); 03243 return dbg; 03244 Q_UNUSED(o); 03245 #endif 03246 }
| Q_DECLARE_TYPEINFO | ( | QConnection | , | |
| Q_MOVABLE_TYPE | ||||
| ) |
| Q_CORE_EXPORT void qt_addObject | ( | QObject * | object | ) |
Definition at line 241 of file qobject.cpp.
References QObjectPrivate::readWriteLock(), and set().
Referenced by QObject::QObject().
00242 { 00243 QWriteLocker locker(QObjectPrivate::readWriteLock()); 00244 QObjectSet *set = allObjects(); 00245 if (set) 00246 set->insert(object); 00247 }
Here is the call graph for this function:

Definition at line 261 of file qobject.cpp.
References QObjectPrivate::readWriteLock(), and set().
00262 { 00263 QList<QObject *> list; 00264 00265 QReadLocker locker(QObjectPrivate::readWriteLock()); 00266 const QObjectSet *set = allObjects(); 00267 if (!set) 00268 return list; 00269 00270 for (QSet<QObject *>::const_iterator it = set->constBegin(); it != set->constEnd(); ++it) { 00271 if ((*it)->isWidgetType() && !(*it)->parent()) 00272 list << *it; 00273 } 00274 00275 return list; 00276 }
Here is the call graph for this function:

| QObject* qt_qFindChild_helper | ( | const QObject * | parent, | |
| const QString & | name, | |||
| const QMetaObject & | mo | |||
| ) |
Definition at line 1780 of file qobject.cpp.
References QMetaObject::cast(), QObject::children(), i, name, QObject::objectName(), QObject::QObjectList(), and qt_qFindChild_helper().
Referenced by qFindChild(), and qt_qFindChild_helper().
01781 { 01782 if (!parent) 01783 return 0; 01784 const QObjectList &children = parent->children(); 01785 QObject *obj; 01786 int i; 01787 for (i = 0; i < children.size(); ++i) { 01788 obj = children.at(i); 01789 if (mo.cast(obj) && (name.isNull() || obj->objectName() == name)) 01790 return obj; 01791 } 01792 for (i = 0; i < children.size(); ++i) { 01793 obj = qt_qFindChild_helper(children.at(i), name, mo); 01794 if (obj) 01795 return obj; 01796 } 01797 return 0; 01798 }
Here is the call graph for this function:

| void qt_qFindChildren_helper | ( | const QObject * | parent, | |
| const QString & | name, | |||
| const QRegExp * | re, | |||
| const QMetaObject & | mo, | |||
| QList< void * > * | list | |||
| ) |
Definition at line 1756 of file qobject.cpp.
References QList< T >::append(), QMetaObject::cast(), QObject::children(), i, name, QObject::objectName(), QObject::QObjectList(), and qt_qFindChildren_helper().
Referenced by qFindChildren(), and qt_qFindChildren_helper().
01758 { 01759 if (!parent || !list) 01760 return; 01761 const QObjectList &children = parent->children(); 01762 QObject *obj; 01763 for (int i = 0; i < children.size(); ++i) { 01764 obj = children.at(i); 01765 if (mo.cast(obj)) { 01766 if (re) { 01767 if (re->indexIn(obj->objectName()) != -1) 01768 list->append(obj); 01769 } else { 01770 if (name.isNull() || obj->objectName() == name) 01771 list->append(obj); 01772 } 01773 } 01774 qt_qFindChildren_helper(obj, name, re, mo, list); 01775 } 01776 }
Here is the call graph for this function:

| Q_CORE_EXPORT void qt_removeObject | ( | QObject * | object | ) |
Definition at line 249 of file qobject.cpp.
Referenced by QObject::~QObject().
00250 { 00251 QObjectSet *set = allObjects(); 00252 if (set) 00253 set->remove(object); 00254 }
Here is the call graph for this function:

| static void queued_activate | ( | QObject * | sender, | |
| const QConnection & | c, | |||
| void ** | argv, | |||
| int | idFrom, | |||
| int | idTo | |||
| ) | [static] |
Definition at line 2829 of file qobject.cpp.
References c, QMetaType::construct(), DIRECT_CONNECTION_ONLY, m, n, QCoreApplication::postEvent(), q_atomic_test_and_set_ptr(), qFree(), qMalloc(), queuedConnectionTypes(), types, and x.
Referenced by QMetaObject::activate().
02830 { 02831 if (!c.types || c.types != &DIRECT_CONNECTION_ONLY) { 02832 QMetaMethod m = sender->metaObject()->method(c.signal); 02833 QConnection &x = const_cast<QConnection &>(c); 02834 int *tmp = ::queuedConnectionTypes(m.parameterTypes()); 02835 if (!tmp) // cannot queue arguments 02836 tmp = &DIRECT_CONNECTION_ONLY; 02837 if (!q_atomic_test_and_set_ptr(&x.types, 0, tmp)) { 02838 if (tmp != &DIRECT_CONNECTION_ONLY) 02839 qFree(tmp); 02840 } 02841 } 02842 if (c.types == &DIRECT_CONNECTION_ONLY) // cannot activate 02843 return; 02844 int nargs = 1; // include return type 02845 while (c.types[nargs-1]) { ++nargs; } 02846 int *types = (int *) qMalloc(nargs*sizeof(int)); 02847 void **args = (void **) qMalloc(nargs*sizeof(void *)); 02848 types[0] = 0; // return type 02849 args[0] = 0; // return value 02850 for (int n = 1; n < nargs; ++n) 02851 args[n] = QMetaType::construct((types[n] = c.types[n-1]), argv[n]); 02852 QCoreApplication::postEvent(c.receiver, new QMetaCallEvent(c.method, 02853 sender, 02854 idFrom, 02855 idTo, 02856 nargs, 02857 types, 02858 args)); 02859 }
Here is the call graph for this function:

| static int* queuedConnectionTypes | ( | const QList< QByteArray > & | typeNames | ) | [static] |
Definition at line 51 of file qobject.cpp.
References QList< T >::at(), QList< T >::count(), i, qFree(), qMalloc(), qWarning(), QMetaType::type(), typeName, types, and QMetaType::VoidStar.
Referenced by QObject::connect(), and queued_activate().
00052 { 00053 int *types = static_cast<int *>(qMalloc((typeNames.count() + 1) * sizeof(int))); 00054 for (int i = 0; i < typeNames.count(); ++i) { 00055 const QByteArray typeName = typeNames.at(i); 00056 if (typeName.endsWith('*')) 00057 types[i] = QMetaType::VoidStar; 00058 else 00059 types[i] = QMetaType::type(typeName); 00060 00061 if (!types[i]) { 00062 qWarning("QObject::connect: Cannot queue arguments of type '%s'\n" 00063 "(Make sure '%s' is registed using qRegisterMetaType().)", 00064 typeName.constData(), typeName.constData()); 00065 qFree(types); 00066 return 0; 00067 } 00068 } 00069 types[typeNames.count()] = 0; 00070 00071 return types; 00072 }
Here is the call graph for this function:

int DIRECT_CONNECTION_ONLY = 0 [static] |
Definition at line 46 of file qobject.cpp.
Referenced by queued_activate(), QConnectionList::remove(), and QConnectionList::removeConnection().
1.5.1