QObjectPrivate Class Reference

#include <qobject_p.h>

Inheritance diagram for QObjectPrivate:

Inheritance graph
[legend]
Collaboration diagram for QObjectPrivate:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 67 of file qobject_p.h.

Public Member Functions

 QObjectPrivate (int version=QObjectPrivateVersion)
virtual ~QObjectPrivate ()
void moveToThread_helper ()
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
void _q_reregisterTimers (void *pointer)
bool isSender (const QObject *receiver, const char *signal) const
QObjectList receiverList (const char *signal) const
QObjectList senderList () const
void setParent_helper (QObject *)
void deleteChildren ()

Static Public Member Functions

static QReadWriteLockreadWriteLock ()
static bool isValidObject (QObject *object)
static void clearGuards (QObject *)

Public Attributes

QThreadDatathreadData
union {
   QObject *   currentSender
   QObject *   currentChildBeingDeleted
}; 
int currentSenderSignalIdStart
int currentSenderSignalIdEnd
QList< QPointer< QObject > > eventFilters
ExtraDataextraData
QString objectName

Classes

struct  ExtraData


Constructor & Destructor Documentation

QObjectPrivate::QObjectPrivate ( int  version = QObjectPrivateVersion  ) 

Definition at line 288 of file qobject.cpp.

References QObjectData::blockSig, extraData, QObjectData::isWidget, QObjectData::parent, QObjectData::pendTimer, QObjectData::postedEvents, QObjectData::q_ptr, QObjectPrivateVersion, QObjectData::receiveChildEvents, QObjectData::sendChildEvents, and QObjectData::wasDeleted.

00289     : threadData(0), currentSender(0), currentSenderSignalIdStart(-1), currentSenderSignalIdEnd(-1)
00290 {
00291     if (version != QObjectPrivateVersion)
00292         qFatal("Cannot mix incompatible Qt libraries");
00293 
00294     // QObjectData initialization
00295     q_ptr = 0;
00296     parent = 0;                                 // no parent yet. It is set by setParent()
00297     isWidget = false;                           // assume not a widget object
00298     pendTimer = false;                          // no timers yet
00299     blockSig = false;                           // not blocking signals
00300     wasDeleted = false;                         // double-delete catcher
00301     sendChildEvents = true;                     // if we should send ChildInsert and ChildRemove events to parent
00302     receiveChildEvents = true;
00303     postedEvents = 0;
00304 #ifdef QT3_SUPPORT
00305     postedChildInsertedEvents = 0;
00306 #endif
00307     extraData = 0;
00308 }

QObjectPrivate::~QObjectPrivate (  )  [virtual]

Definition at line 310 of file qobject.cpp.

References extraData, qDeleteAll(), and QObjectPrivate::ExtraData::userData.

00311 {
00312 #ifndef QT_NO_USERDATA
00313     if (extraData)
00314         qDeleteAll(extraData->userData);
00315     delete extraData;
00316 #endif
00317 }

Here is the call graph for this function:


Member Function Documentation

QReadWriteLock * QObjectPrivate::readWriteLock (  )  [static]

Definition at line 49 of file qobject.cpp.

Referenced by QObject::event(), QObject::installEventFilter(), QObject::moveToThread(), QApplication::notify(), QCoreApplicationPrivate::notify_helper(), QApplicationPrivate::notify_helper(), QCoreApplication::postEvent(), qt_addObject(), qt_allTopLevelWidgets(), QObject::removeEventFilter(), and QObject::~QObject().

00049 { return qt_object_read_write_lock(); }

bool QObjectPrivate::isValidObject ( QObject object  )  [static]

Definition at line 282 of file qobject.cpp.

References object, and set().

Referenced by QObject::event(), and QCoreApplication::postEvent().

00283 {
00284     QObjectSet *set = allObjects();
00285     return set ? set->contains(object) : false;
00286 }

Here is the call graph for this function:

void QObjectPrivate::moveToThread_helper (  ) 

Definition at line 1332 of file qobject.cpp.

References i, QCoreApplication::sendEvent(), and QEvent::ThreadChange.

01333 {
01334     Q_Q(QObject);
01335     QEvent e(QEvent::ThreadChange);
01336     QCoreApplication::sendEvent(q, &e);
01337     for (int i = 0; i < children.size(); ++i) {
01338         QObject *child = children.at(i);
01339         child->d_func()->moveToThread_helper();
01340     }
01341 }

Here is the call graph for this function:

void QObjectPrivate::setThreadData_helper ( QThreadData currentData,
QThreadData targetData 
)

Definition at line 1343 of file qobject.cpp.

References QList< T >::append(), QList< T >::at(), QThreadData::deref(), QThreadData::eventDispatcher, i, QThreadData::postEventList, QThreadData::ref(), QList< T >::size(), threadData, and QAbstractEventDispatcher::wakeUp().

01344 {
01345     Q_Q(QObject);
01346 
01347     // move posted events
01348     int eventsMoved = 0;
01349     for (int i = 0; i < currentData->postEventList.size(); ++i) {
01350         const QPostEvent &pe = currentData->postEventList.at(i);
01351         if (!pe.event)
01352             continue;
01353         if (pe.receiver == q) {
01354             // move this post event to the targetList
01355             targetData->postEventList.append(pe);
01356             const_cast<QPostEvent &>(pe).event = 0;
01357             ++eventsMoved;
01358         }
01359     }
01360     if (eventsMoved > 0 && targetData->eventDispatcher)
01361         targetData->eventDispatcher->wakeUp();
01362 
01363     // set new thread data
01364     targetData->ref();
01365     threadData->deref();
01366     threadData = targetData;
01367 
01368     for (int i = 0; i < children.size(); ++i) {
01369         QObject *child = children.at(i);
01370         child->d_func()->setThreadData_helper(currentData, targetData);
01371     }
01372 }

Here is the call graph for this function:

void QObjectPrivate::_q_reregisterTimers ( void *  pointer  ) 

Definition at line 1374 of file qobject.cpp.

References QList< T >::at(), QThreadData::eventDispatcher, i, QList< T >::size(), and threadData.

01375 {
01376     Q_Q(QObject);
01377     QList<QPair<int, int> > *timerList = reinterpret_cast<QList<QPair<int, int> > *>(pointer);
01378     QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
01379     for (int i = 0; i < timerList->size(); ++i) {
01380         const QPair<int, int> &pair = timerList->at(i);
01381         eventDispatcher->registerTimer(pair.first, pair.second, q);
01382     }
01383     delete timerList;
01384 }

Here is the call graph for this function:

bool QObjectPrivate::isSender ( const QObject receiver,
const char *  signal 
) const

Definition at line 319 of file qobject.cpp.

References List< T >::at(), c, QConnectionList::connections, QHash< Key, T >::const_iterator, QConnectionList::lock, and QConnectionList::sendersHash.

00320 {
00321     Q_Q(const QObject);
00322     int signal_index = q->metaObject()->indexOfSignal(signal);
00323     if (signal_index < 0)
00324         return false;
00325     QConnectionList *list = ::connectionList();
00326     QReadLocker locker(&list->lock);
00327     QConnectionList::Hash::const_iterator it = list->sendersHash.constFind(q);
00328     while (it != list->sendersHash.constEnd() && it.key() == q) {
00329         const QConnection &c = list->connections.at(it.value());
00330         if (c.signal == signal_index && c.receiver == receiver)
00331             return true;
00332         ++it;
00333     }
00334     return false;
00335 }

Here is the call graph for this function:

QObjectList QObjectPrivate::receiverList ( const char *  signal  )  const

Definition at line 337 of file qobject.cpp.

References List< T >::at(), c, QConnectionList::connections, QHash< Key, T >::const_iterator, QConnectionList::lock, and QConnectionList::sendersHash.

00338 {
00339     Q_Q(const QObject);
00340     QObjectList receivers;
00341     int signal_index = q->metaObject()->indexOfSignal(signal);
00342     if (signal_index < 0)
00343         return receivers;
00344     QConnectionList *list = ::connectionList();
00345     QReadLocker locker(&list->lock);
00346     QConnectionList::Hash::const_iterator it = list->sendersHash.constFind(q);
00347     while (it != list->sendersHash.constEnd() && it.key() == q) {
00348         const QConnection &c = list->connections.at(it.value());
00349         if (c.signal == signal_index)
00350             receivers << c.receiver;
00351         ++it;
00352     }
00353     return receivers;
00354 }

Here is the call graph for this function:

QObjectList QObjectPrivate::senderList (  )  const

Definition at line 356 of file qobject.cpp.

References List< T >::at(), c, QConnectionList::connections, QHash< Key, T >::const_iterator, QConnectionList::lock, and QConnectionList::receiversHash.

00357 {
00358     Q_Q(const QObject);
00359     QObjectList senders;
00360     QConnectionList *list = ::connectionList();
00361     QReadLocker locker(&list->lock);
00362     QConnectionList::Hash::const_iterator it = list->receiversHash.constFind(q);
00363     while (it != list->receiversHash.constEnd() && it.key() == q) {
00364         const QConnection &c = list->connections.at(it.value());
00365         senders << c.sender;
00366         ++it;
00367     }
00368     return senders;
00369 }

Here is the call graph for this function:

void QObjectPrivate::setParent_helper ( QObject  ) 

Definition at line 1830 of file qobject.cpp.

References QList< T >::append(), QEvent::ChildAdded, QEvent::ChildRemoved, QObjectData::children, QObject::children(), currentChildBeingDeleted, index, QList< T >::indexOf(), QObjectData::isWidget, o, QObjectData::parent, QCoreApplication::postEvent(), qWarning(), QObjectData::receiveChildEvents, QList< T >::removeAt(), QObjectData::sendChildEvents, QCoreApplication::sendEvent(), threadData, and QObjectData::wasDeleted.

Referenced by QWidgetPrivate::setParent_sys().

01831 {
01832     Q_Q(QObject);
01833     if (o == parent)
01834         return;
01835     if (parent) {
01836         QObjectPrivate *parentD = parent->d_func();
01837         if (parentD->wasDeleted && wasDeleted
01838             && parentD->currentChildBeingDeleted == q) {
01839             // don't do anything since QObjectPrivate::deleteChildren() already
01840             // cleared our entry in parentD->children.
01841         } else {
01842             const int index = parentD->children.indexOf(q);
01843             if (parentD->wasDeleted) {
01844                 parentD->children[index] = 0;
01845             } else {
01846                 parentD->children.removeAt(index);
01847                 if (sendChildEvents && parentD->receiveChildEvents) {
01848                     QChildEvent e(QEvent::ChildRemoved, q);
01849                     QCoreApplication::sendEvent(parent, &e);
01850                 }
01851             }
01852         }
01853     }
01854     parent = o;
01855     if (parent) {
01856         // object hierarchies are constrained to a single thread
01857         if (threadData != parent->d_func()->threadData) {
01858             qWarning("QObject::setParent: New parent must be in the same thread as the previous parent");
01859             parent = 0;
01860             return;
01861         }
01862         parent->d_func()->children.append(q);
01863         if(sendChildEvents && parent->d_func()->receiveChildEvents) {
01864             if (!isWidget) {
01865                 QChildEvent e(QEvent::ChildAdded, q);
01866                 QCoreApplication::sendEvent(parent, &e);
01867 #ifdef QT3_SUPPORT
01868                 QCoreApplication::postEvent(parent, new QChildEvent(QEvent::ChildInserted, q));
01869 #endif
01870             }
01871         }
01872     }
01873 }

Here is the call graph for this function:

void QObjectPrivate::deleteChildren (  ) 

Definition at line 1813 of file qobject.cpp.

References currentChildBeingDeleted, i, and QObjectData::wasDeleted.

01814 {
01815     const bool reallyWasDeleted = wasDeleted;
01816     wasDeleted = true;
01817     // delete children objects
01818     // don't use qDeleteAll as the destructor of the child might
01819     // delete siblings
01820     for (int i = 0; i < children.count(); ++i) {
01821         currentChildBeingDeleted = children.at(i);
01822         children[i] = 0;
01823         delete currentChildBeingDeleted;
01824     }
01825     children.clear();
01826     currentChildBeingDeleted = 0;
01827     wasDeleted = reallyWasDeleted;
01828 }

void QObjectPrivate::clearGuards ( QObject  )  [static]

Definition at line 437 of file qobject.cpp.

References QHash< Key, T >::end(), QHash< Key, T >::erase(), QHash< Key, T >::find(), QHash< Key, T >::iterator, and object.

Referenced by QObject::~QObject(), and QWidget::~QWidget().

00438 {
00439     GuardHash *hash = ::guardHash();
00440     if (hash) {
00441         QWriteLocker locker(guardHashLock());
00442         GuardHash::iterator it = hash->find(object);
00443         const GuardHash::iterator end = hash->end();
00444         while (it.key() == object && it != end) {
00445             *it.value() = 0;
00446             it = hash->erase(it);
00447         }
00448     }
00449 }

Here is the call graph for this function:


Member Data Documentation

QThreadData* QObjectPrivate::threadData

Definition at line 81 of file qobject_p.h.

Referenced by QAbstractSocketPrivate::_q_connectToNextAddress(), _q_reregisterTimers(), QAbstractSocketPrivate::_q_testConnection(), QProcessPrivate::createChannel(), QAbstractEventDispatcherPrivate::init(), QAbstractSocketPrivate::initSocketLayer(), setParent_helper(), setThreadData_helper(), QProcessPrivate::startProcess(), and QCoreApplicationPrivate::~QCoreApplicationPrivate().

QObject* QObjectPrivate::currentSender

Definition at line 88 of file qobject_p.h.

QObject* QObjectPrivate::currentChildBeingDeleted

Definition at line 89 of file qobject_p.h.

Referenced by deleteChildren(), and setParent_helper().

union { ... }

int QObjectPrivate::currentSenderSignalIdStart

Definition at line 91 of file qobject_p.h.

int QObjectPrivate::currentSenderSignalIdEnd

Definition at line 92 of file qobject_p.h.

QList<QPointer<QObject> > QObjectPrivate::eventFilters

Definition at line 98 of file qobject_p.h.

Referenced by QCoreApplicationPrivate::notify_helper(), and QApplicationPrivate::notify_helper().

ExtraData* QObjectPrivate::extraData

Definition at line 114 of file qobject_p.h.

Referenced by QObjectPrivate(), and ~QObjectPrivate().

QString QObjectPrivate::objectName

Definition at line 116 of file qobject_p.h.


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 18:32:10 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1