Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Public Variables | List of all members
QObjectPrivate Class Reference

#include <qobject_p.h>

Inheritance diagram for QObjectPrivate:
QObjectData QAbstractAnimationPrivate QAbstractEventDispatcherPrivate QAbstractFontEnginePrivate QAbstractItemModelPrivate QAbstractMessageHandlerPrivate QAbstractNetworkCachePrivate QAbstractSocketEnginePrivate QAbstractStatePrivate QAbstractTextDocumentLayoutPrivate QAbstractTransitionPrivate QAbstractVideoSurfacePrivate QActionGroupPrivate QActionPrivate QAnimationDriverPrivate QButtonGroupPrivate QClipboardPrivate QCompleterPrivate QCoreApplicationPrivate QDataWidgetMapperPrivate QDBusAbstractAdaptorPrivate QDBusAbstractInterfacePrivate QDBusPendingCallWatcherPrivate QDeclarativeAbstractAnimationPrivate QDeclarativeAnchorSetPrivate QDeclarativeAnchorsPrivate QDeclarativeApplicationPrivate QDeclarativeBehaviorPrivate QDeclarativeBindPrivate QDeclarativeCompiledBindingsPrivate QDeclarativeComponentPrivate QDeclarativeConnectionsPrivate QDeclarativeContextPrivate QDeclarativeDebugClientPrivate QDeclarativeDebugServerPrivate QDeclarativeDebugServicePrivate QDeclarativeEngineDebugPrivate QDeclarativeEnginePrivate QDeclarativeExpressionPrivate QDeclarativeFontLoaderPrivate QDeclarativeGraphicsWidgetPrivate QDeclarativeKeyNavigationAttachedPrivate QDeclarativeKeysAttachedPrivate QDeclarativePackagePrivate QDeclarativePathPrivate QDeclarativePropertyMapPrivate QDeclarativeStateGroupPrivate QDeclarativeStateOperationPrivate QDeclarativeStatePrivate QDeclarativeSystemPalettePrivate QDeclarativeTimerPrivate QDeclarativeTransitionPrivate QDeclarativeVisualDataModelPrivate QDeclarativeVisualItemModelPrivate QDeclarativeXmlListModelPrivate QDirectPainterPrivate QDragPrivate QEventLoopPrivate QFactoryLoaderPrivate QFileSystemWatcherPrivate QFontEnginePluginPrivate QFtpPrivate QFutureWatcherBasePrivate QGesturePrivate QGLShaderPrivate QGLShaderProgramPrivate QGraphicsAnchorPrivate QGraphicsEffectPrivate QGraphicsEffectSourcePrivate QGraphicsSceneIndexPrivate QGraphicsScenePrivate QGraphicsTransformPrivate QHttpMultiPartPrivate QHttpNetworkConnectionPrivate QHttpNetworkReplyPrivate QHttpPrivate QInputContextPrivate QIODevicePrivate QItemDelegatePrivate QItemSelectionModelPrivate QKeyMapperPrivate QLayoutPrivate QLocalServerPrivate QMimeDataPrivate QMoviePrivate QNetworkAccessManagerPrivate QNetworkCookieJarPrivate QPixmapFilterPrivate QScriptCompletionTaskInterfacePrivate QScriptDebuggerConsoleGlobalObjectPrivate QScriptDebuggerPrivate QScriptEngineDebuggerPrivate QScriptEnginePrivate QSessionManagerPrivate QSessionManagerPrivate QSessionManagerPrivate QSessionManagerPrivate QSettingsPrivate QSharedMemoryPrivate QShortcutPrivate QSignalMapperPrivate QSoftKeyManagerPrivate QSoundPrivate QSqlDriverPrivate QStyledItemDelegatePrivate QStylePrivate QSvgRendererPrivate QSyntaxHighlighterPrivate QSystemTrayIconPrivate QTcpServerPrivate QTextControlPrivate QTextDocumentPrivate QTextObjectPrivate QThreadPoolPrivate QThreadPrivate QTimeLinePrivate QTranslatorPrivate QTransportAuthPrivate QUndoGroupPrivate QUndoStackPrivate QValidatorPrivate QWidgetPrivate QWSClientPrivate QWSServerPrivate

Classes

struct  Connection
 
struct  ConnectionList
 
struct  ExtraData
 
struct  Sender
 

Public Types

typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Public Functions

void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Detailed Description

Definition at line 98 of file qobject_p.h.

Typedefs

◆ StaticMetaCallFunction

typedef void(* QObjectPrivate::StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)

Definition at line 113 of file qobject_p.h.

Constructors and Destructors

◆ QObjectPrivate()

QObjectPrivate::QObjectPrivate ( int  version = QObjectPrivateVersion)

Definition at line 133 of file qobject.cpp.

135 {
136  if (version != QObjectPrivateVersion)
137  qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)",
138  version, QObjectPrivateVersion);
139 
140  // QObjectData initialization
141  q_ptr = 0;
142  parent = 0; // no parent yet. It is set by setParent()
143  isWidget = false; // assume not a widget object
144  pendTimer = false; // no timers yet
145  blockSig = false; // not blocking signals
146  wasDeleted = false; // double-delete catcher
147  sendChildEvents = true; // if we should send ChildInsert and ChildRemove events to parent
148  receiveChildEvents = true;
149  postedEvents = 0;
150  extraData = 0;
152  inThreadChangeEvent = false;
153 #ifdef QT_JAMBI_BUILD
154  inEventHandler = false;
155  deleteWatch = 0;
156 #endif
157  metaObject = 0;
158  hasGuards = false;
159 }
QObject * q_ptr
Definition: qobject.h:91
Connection * senders
Definition: qobject_p.h:199
uint hasGuards
Definition: qobject.h:104
uint wasDeleted
Definition: qobject.h:98
uint isWidget
Definition: qobject.h:95
Sender * currentSender
Definition: qobject_p.h:200
QThreadData * threadData
Definition: qobject_p.h:195
uint blockSig
Definition: qobject.h:97
uint inThreadChangeEvent
Definition: qobject.h:103
quint32 connectedSignals[2]
Definition: qobject_p.h:201
uint inEventHandler
Definition: qobject.h:102
Q_CORE_EXPORT void qFatal(const char *,...)
ExtraData * extraData
Definition: qobject_p.h:194
QMetaObject * metaObject
Definition: qobject.h:107
QObject * parent
Definition: qobject.h:92
QObject * currentChildBeingDeleted
Definition: qobject_p.h:213
uint sendChildEvents
Definition: qobject.h:100
uint pendTimer
Definition: qobject.h:96
int postedEvents
Definition: qobject.h:106
uint receiveChildEvents
Definition: qobject.h:101
QObjectConnectionListVector * connectionLists
Definition: qobject_p.h:197

◆ ~QObjectPrivate()

QObjectPrivate::~QObjectPrivate ( )
virtual

Definition at line 161 of file qobject.cpp.

162 {
163  if (pendTimer) {
164  // unregister pending timers
167  }
168 
169  if (postedEvents)
171 
172  if (threadData)
173  threadData->deref();
174 
175  delete static_cast<QAbstractDynamicMetaObject*>(metaObject);
176 #ifdef QT_JAMBI_BUILD
177  if (deleteWatch)
178  *deleteWatch = 1;
179 #endif
180 #ifndef QT_NO_USERDATA
181  if (extraData)
183  delete extraData;
184 #endif
185 }
QObject * q_ptr
Definition: qobject.h:91
QThreadData * threadData
Definition: qobject_p.h:195
void deref()
Definition: qthread.cpp:125
QVector< QObjectUserData * > userData
Definition: qobject_p.h:107
ExtraData * extraData
Definition: qobject_p.h:194
QMetaObject * metaObject
Definition: qobject.h:107
removePostedEvents
Removes all events of the given eventType that were posted using postEvent() for receiver.
uint pendTimer
Definition: qobject.h:96
int postedEvents
Definition: qobject.h:106
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
QAbstractEventDispatcher * eventDispatcher
Definition: qthread_p.h:264
virtual bool unregisterTimers(QObject *object)=0
Unregisters all the timers associated with the given object.

Functions

◆ _q_reregisterTimers()

void QObjectPrivate::_q_reregisterTimers ( void *  pointer)

Definition at line 1571 of file qobject.cpp.

1572 {
1573  Q_Q(QObject);
1574  QList<QPair<int, int> > *timerList = reinterpret_cast<QList<QPair<int, int> > *>(pointer);
1576  for (int i = 0; i < timerList->size(); ++i) {
1577  const QPair<int, int> &pair = timerList->at(i);
1578  eventDispatcher->registerTimer(pair.first, pair.second, q);
1579  }
1580  delete timerList;
1581 }
T1 first
Definition: qpair.h:65
T2 second
Definition: qpair.h:66
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QThreadData * threadData
Definition: qobject_p.h:195
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QAbstractEventDispatcher * eventDispatcher
Definition: qthread_p.h:264
The QAbstractEventDispatcher class provides an interface to manage Qt&#39;s event queue.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ addConnection()

void QObjectPrivate::addConnection ( int  signal,
Connection c 
)

Definition at line 330 of file qobject.cpp.

Referenced by QMetaObjectPrivate::connect().

331 {
332  if (!connectionLists)
334  if (signal >= connectionLists->count())
335  connectionLists->resize(signal + 1);
336 
337  ConnectionList &connectionList = (*connectionLists)[signal];
338  if (connectionList.last) {
339  connectionList.last->nextConnectionList = c;
340  } else {
341  connectionList.first = c;
342  }
343  connectionList.last = c;
344 
346 }
unsigned char c[8]
Definition: qnumeric_p.h:62
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
void cleanConnectionLists()
Definition: qobject.cpp:348
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QObjectConnectionListVector * connectionLists
Definition: qobject_p.h:197

◆ cleanConnectionLists()

void QObjectPrivate::cleanConnectionLists ( )

Definition at line 348 of file qobject.cpp.

Referenced by addConnection().

349 {
351  // remove broken connections
352  for (int signal = -1; signal < connectionLists->count(); ++signal) {
353  QObjectPrivate::ConnectionList &connectionList =
354  (*connectionLists)[signal];
355 
356  // Set to the last entry in the connection list that was *not*
357  // deleted. This is needed to update the list's last pointer
358  // at the end of the cleanup.
359  QObjectPrivate::Connection *last = 0;
360 
361  QObjectPrivate::Connection **prev = &connectionList.first;
362  QObjectPrivate::Connection *c = *prev;
363  while (c) {
364  if (c->receiver) {
365  last = c;
366  prev = &c->nextConnectionList;
367  c = *prev;
368  } else {
370  *prev = next;
371  delete c;
372  c = next;
373  }
374  }
375 
376  // Correct the connection list's last pointer.
377  // As conectionList.last could equal last, this could be a noop
378  connectionList.last = last;
379  }
380  connectionLists->dirty = false;
381  }
382 }
unsigned char c[8]
Definition: qnumeric_p.h:62
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
Connection * nextConnectionList
Definition: qobject_p.h:120
QObjectConnectionListVector * connectionLists
Definition: qobject_p.h:197

◆ clearGuards()

void QObjectPrivate::clearGuards ( QObject object)
static
Warning
This function is not part of the public interface.

Definition at line 467 of file qobject.cpp.

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

468 {
469  GuardHash *hash = 0;
470  QMutex *mutex = 0;
471  QT_TRY {
472  hash = guardHash();
473  mutex = guardHashLock();
474  } QT_CATCH(const std::bad_alloc &) {
475  // do nothing in case of OOM - code below is safe
476  }
477 
478  /* check that the hash is empty - otherwise we might detach
479  the shared_null hash, which will alloc, which is not nice */
480  if (hash && !hash->isEmpty()) {
481  QMutexLocker locker(mutex);
482  GuardHash::iterator it = hash->find(object);
483  const GuardHash::iterator end = hash->end();
484  while (it.key() == object && it != end) {
485  *it.value() = 0;
486  it = hash->erase(it);
487  }
488  }
489 }
The QMultiHash class is a convenience QHash subclass that provides multi-valued hashes.
Definition: qcontainerfwd.h:58
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
#define it(className, varName)
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
QHash< Key, T >::iterator find(const Key &key, const T &value)
Returns an iterator pointing to the item with the key and value.
Definition: qhash.h:972
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
const Key & key() const
Returns the current item&#39;s key as a const reference.
Definition: qhash.h:347
#define QT_CATCH(A)
Definition: qglobal.h:1537
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
static const KeyPair *const end
#define QT_TRY
Definition: qglobal.h:1536
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827

◆ connectNotify()

void QObjectPrivate::connectNotify ( const char *  signal)
inline

Definition at line 245 of file qobject_p.h.

Referenced by QDeclarativePropertyPrivate::connect().

246 {
247  q_ptr->connectNotify(signal);
248 }
QObject * q_ptr
Definition: qobject.h:91
virtual void connectNotify(const char *signal)
This virtual function is called when something has been connected to signal in this object...
Definition: qobject.cpp:3142

◆ deleteChildren()

void QObjectPrivate::deleteChildren ( )

Definition at line 1957 of file qobject.cpp.

Referenced by QObject::~QObject().

1958 {
1959  const bool reallyWasDeleted = wasDeleted;
1960  wasDeleted = true;
1961  // delete children objects
1962  // don't use qDeleteAll as the destructor of the child might
1963  // delete siblings
1964  for (int i = 0; i < children.count(); ++i) {
1966  children[i] = 0;
1967  delete currentChildBeingDeleted;
1968  }
1969  children.clear();
1971  wasDeleted = reallyWasDeleted;
1972 }
uint wasDeleted
Definition: qobject.h:98
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QObjectList children
Definition: qobject.h:93
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void clear()
Removes all items from the list.
Definition: qlist.h:764
QObject * currentChildBeingDeleted
Definition: qobject_p.h:213

◆ disconnectNotify()

void QObjectPrivate::disconnectNotify ( const char *  signal)
inline

Definition at line 250 of file qobject_p.h.

Referenced by QDeclarativeNotifierEndpoint::disconnect().

251 {
252  q_ptr->disconnectNotify(signal);
253 }
QObject * q_ptr
Definition: qobject.h:91
virtual void disconnectNotify(const char *signal)
This virtual function is called when something has been disconnected from signal in this object...
Definition: qobject.cpp:3162

◆ get()

static QObjectPrivate* QObjectPrivate::get ( QObject o)
inlinestatic

Definition at line 177 of file qobject_p.h.

Referenced by QAbstractScrollAreaPrivate::_q_showOrHideScrollBars(), QDeclarativeGuardImpl::addGuard(), QDeclarativeEnginePrivate::cache(), QInternal::callFunction(), QMetaObject::changeGuard(), QDeclarativeTransitionManager::complete(), QDeclarativePropertyPrivate::connect(), QMetaObjectPrivate::connect(), QDeclarativeEngine::contextForObject(), QDeclarativeCompiledData::TypeReference::createInstance(), QScriptDeclarativeClass::createPersistentIdentifier(), destroy_current_thread_data(), QDeclarativeNotifierEndpoint::disconnect(), QDeclarativeBoundSignal::disconnect(), QMetaObjectPrivate::disconnect(), QScriptDebuggerLocalsItemDelegate::eventFilter(), QEventLoop::exec(), fastHasBinding(), flush_vme_signal(), QDeclarativeContextPrivate::get(), QDeclarativeComponentPrivate::get(), QDeclarativeData::get(), QDeclarativeExpressionPrivate::get(), QDeclarativeVisualDataModelPrivate::get(), QDeclarativeDebugServer::instance(), QDeclarativeMouseAreaPrivate::isDoubleClickConnected(), QDeclarativeMouseAreaPrivate::isPressAndHoldConnected(), QDeclarativeContextData::isValid(), QScriptDeclarativeClass::newObject(), QScriptDeclarativeClass::newObjectValue(), QDeclarativeObjectScriptClass::newQObject(), QDeclarativeContextData::ContextGuard::objectDestroyed(), QDeclarativeValueTypeScriptClass::property(), QDeclarativePrivate::qdeclarativeelement_destructor(), QDeclarativeOpenMetaObject::QDeclarativeOpenMetaObject(), QDeclarativeProxyMetaObject::QDeclarativeProxyMetaObject(), QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(), qDeleteInEventHandler(), qt_adopted_thread_watcher_function(), QStateMachinePrivate::registerEventTransition(), QDeclarativeVisualDataModel::release(), QDeclarativeEngineDebugPrivate::remove(), QMetaObject::removeGuard(), QDeclarativeVME::run(), QDeclarativeStateGroupPrivate::setCurrentStateInternal(), QDeclarativeConnectionsParser::setCustomData(), QDeclarativePropertyChangesParser::setCustomData(), QDeclarativeEngineDebugService::setMethodBody(), QAbstractScrollAreaPrivate::setSingleFingerPanEnabled(), QComboBox::showPopup(), QTimerInfoList::unregisterTimer(), QEventDispatcherMac::unregisterTimer(), QEventDispatcherWin32Private::unregisterTimer(), QTimerInfoList::unregisterTimers(), QEventDispatcherMac::unregisterTimers(), and QGraphicsItem::~QGraphicsItem().

177  {
178  return o->d_func();
179  }

◆ isSender()

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

Definition at line 275 of file qobject.cpp.

276 {
277  Q_Q(const QObject);
278  int signal_index = signalIndex(signal);
279  if (signal_index < 0)
280  return false;
281  QMutexLocker locker(signalSlotLock(q));
282  if (connectionLists) {
283  if (signal_index < connectionLists->count()) {
285  connectionLists->at(signal_index).first;
286 
287  while (c) {
288  if (c->receiver == receiver)
289  return true;
290  c = c->nextConnectionList;
291  }
292  }
293  }
294  return false;
295 }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
static QMutex * signalSlotLock(const QObject *o)
Definition: qobject.cpp:103
Connection * nextConnectionList
Definition: qobject_p.h:120
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QObjectConnectionListVector * connectionLists
Definition: qobject_p.h:197
int signalIndex(const char *signalName) const
Returns the signal index used in the internal connectionLists vector.
Definition: qobject.cpp:3719

◆ isSignalConnected()

bool QObjectPrivate::isSignalConnected ( uint  signal_index) const
inline

Returns true if the signal with index signal_index from object sender is connected.

Warning
This function is not part of the public interface.

Signals with indices above a certain range are always considered connected (see connectedSignals in QObjectPrivate). If a signal spy is installed, all signals are considered connected.

signal_index must be the index returned by QObjectPrivate::signalIndex;

Definition at line 237 of file qobject_p.h.

Referenced by QGraphicsScenePrivate::_q_emitUpdated(), QDeclarativeMouseAreaPrivate::isDoubleClickConnected(), QDeclarativeMouseAreaPrivate::isPressAndHoldConnected(), QGraphicsItem::prepareGeometryChange(), QVariantAnimationPrivate::setCurrentValueForProgress(), and QObject::~QObject().

238 {
239  return signal_index >= sizeof(connectedSignals) * 8
240  || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f))
243 }
BeginCallback signal_begin_callback
Definition: qobject_p.h:79
quint32 connectedSignals[2]
Definition: qobject_p.h:201
EndCallback signal_end_callback
Definition: qobject_p.h:81
QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set

◆ moveToThread_helper()

void QObjectPrivate::moveToThread_helper ( )

Definition at line 1513 of file qobject.cpp.

Referenced by QObject::moveToThread().

1514 {
1515  Q_Q(QObject);
1518  for (int i = 0; i < children.size(); ++i) {
1519  QObject *child = children.at(i);
1520  child->d_func()->moveToThread_helper();
1521  }
1522 }
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObjectList children
Definition: qobject.h:93
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ receiverList()

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

Definition at line 298 of file qobject.cpp.

299 {
300  Q_Q(const QObject);
301  QObjectList returnValue;
302  int signal_index = signalIndex(signal);
303  if (signal_index < 0)
304  return returnValue;
305  QMutexLocker locker(signalSlotLock(q));
306  if (connectionLists) {
307  if (signal_index < connectionLists->count()) {
308  const QObjectPrivate::Connection *c = connectionLists->at(signal_index).first;
309 
310  while (c) {
311  if (c->receiver)
312  returnValue << c->receiver;
313  c = c->nextConnectionList;
314  }
315  }
316  }
317  return returnValue;
318 }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
static QMutex * signalSlotLock(const QObject *o)
Definition: qobject.cpp:103
Connection * nextConnectionList
Definition: qobject_p.h:120
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QObjectConnectionListVector * connectionLists
Definition: qobject_p.h:197
int signalIndex(const char *signalName) const
Returns the signal index used in the internal connectionLists vector.
Definition: qobject.cpp:3719

◆ resetCurrentSender()

void QObjectPrivate::resetCurrentSender ( QObject receiver,
Sender currentSender,
Sender previousSender 
)
inlinestatic

Definition at line 277 of file qobject_p.h.

Referenced by QMetaObject::activate(), QInternal::callFunction(), and QObject::event().

280 {
281  // ref is set to zero when this object is deleted during the metacall
282  if (currentSender->ref == 1)
283  receiver->d_func()->currentSender = previousSender;
284  // if we've recursed, we need to tell the caller about the objects deletion
285  if (previousSender)
286  previousSender->ref = currentSender->ref;
287 }
Sender * currentSender
Definition: qobject_p.h:200

◆ senderList()

QObjectList QObjectPrivate::senderList ( ) const

Definition at line 321 of file qobject.cpp.

322 {
323  QObjectList returnValue;
324  QMutexLocker locker(signalSlotLock(q_func()));
325  for (Connection *c = senders; c; c = c->next)
326  returnValue << c->sender;
327  return returnValue;
328 }
unsigned char c[8]
Definition: qnumeric_p.h:62
Connection * senders
Definition: qobject_p.h:199
static QMutex * signalSlotLock(const QObject *o)
Definition: qobject.cpp:103
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ setCurrentSender()

QObjectPrivate::Sender * QObjectPrivate::setCurrentSender ( QObject receiver,
Sender sender 
)
inlinestatic

Definition at line 269 of file qobject_p.h.

Referenced by QMetaObject::activate(), QInternal::callFunction(), and QObject::event().

271 {
272  Sender *previousSender = receiver->d_func()->currentSender;
273  receiver->d_func()->currentSender = sender;
274  return previousSender;
275 }

◆ setParent_helper()

void QObjectPrivate::setParent_helper ( QObject o)

Definition at line 1974 of file qobject.cpp.

Referenced by QWidgetPrivate::isBackgroundInherited(), isServerProcess(), q_createNativeChildrenAndSetParent(), QObject::setParent(), QWidgetPrivate::setParent_sys(), and QObject::~QObject().

1975 {
1976  Q_Q(QObject);
1977  if (o == parent)
1978  return;
1979  if (parent) {
1980  QObjectPrivate *parentD = parent->d_func();
1981  if (parentD->wasDeleted && wasDeleted
1982  && parentD->currentChildBeingDeleted == q) {
1983  // don't do anything since QObjectPrivate::deleteChildren() already
1984  // cleared our entry in parentD->children.
1985  } else {
1986  const int index = parentD->children.indexOf(q);
1987  if (parentD->wasDeleted) {
1988  parentD->children[index] = 0;
1989  } else {
1990  parentD->children.removeAt(index);
1991  if (sendChildEvents && parentD->receiveChildEvents) {
1994  }
1995  }
1996  }
1997  }
1998  parent = o;
1999  if (parent) {
2000  // object hierarchies are constrained to a single thread
2001  if (threadData != parent->d_func()->threadData) {
2002  qWarning("QObject::setParent: Cannot set parent, new parent is in a different thread");
2003  parent = 0;
2004  return;
2005  }
2006  parent->d_func()->children.append(q);
2007  if(sendChildEvents && parent->d_func()->receiveChildEvents) {
2008  if (!isWidget) {
2011 #ifdef QT3_SUPPORT
2012  if (QCoreApplicationPrivate::useQt3Support) {
2013  if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
2015  new QEvent(QEvent::ChildInsertedRequest),
2017  }
2018  parent->d_func()->pendingChildInsertedEvents.append(q);
2019  }
2020 #endif
2021  }
2022  }
2023  }
2024  if (!wasDeleted && declarativeData)
2026 }
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...
uint wasDeleted
Definition: qobject.h:98
uint isWidget
Definition: qobject.h:95
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObjectList children
Definition: qobject.h:93
QThreadData * threadData
Definition: qobject_p.h:195
#define Q_Q(Class)
Definition: qglobal.h:2483
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Q_CORE_EXPORT void qWarning(const char *,...)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QAbstractDeclarativeData * declarativeData
Definition: qobject_p.h:214
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
static void(* parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *)
Definition: qobject_p.h:94
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
quint16 index
QObject * parent
Definition: qobject.h:92
QObject * currentChildBeingDeleted
Definition: qobject_p.h:213
uint sendChildEvents
Definition: qobject.h:100
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
uint receiveChildEvents
Definition: qobject.h:101
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ setThreadData_helper()

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

Definition at line 1524 of file qobject.cpp.

1525 {
1526  Q_Q(QObject);
1527 
1528  // move posted events
1529  int eventsMoved = 0;
1530  for (int i = 0; i < currentData->postEventList.size(); ++i) {
1531  const QPostEvent &pe = currentData->postEventList.at(i);
1532  if (!pe.event)
1533  continue;
1534  if (pe.receiver == q) {
1535  // move this post event to the targetList
1536  targetData->postEventList.addEvent(pe);
1537  const_cast<QPostEvent &>(pe).event = 0;
1538  ++eventsMoved;
1539  }
1540  }
1541  if (eventsMoved > 0 && targetData->eventDispatcher) {
1542  targetData->canWait = false;
1543  targetData->eventDispatcher->wakeUp();
1544  }
1545 
1546  // the current emitting thread shouldn't restore currentSender after calling moveToThread()
1547  if (currentSender)
1548  currentSender->ref = 0;
1549  currentSender = 0;
1550 
1551 #ifdef QT_JAMBI_BUILD
1552  // the current event thread also shouldn't restore the delete watch
1553  inEventHandler = false;
1554 
1555  if (deleteWatch)
1556  *deleteWatch = 1;
1557  deleteWatch = 0;
1558 #endif
1559 
1560  // set new thread data
1561  targetData->ref();
1562  threadData->deref();
1563  threadData = targetData;
1564 
1565  for (int i = 0; i < children.size(); ++i) {
1566  QObject *child = children.at(i);
1567  child->d_func()->setThreadData_helper(currentData, targetData);
1568  }
1569 }
EventRef event
void addEvent(const QPostEvent &ev)
Definition: qthread_p.h:115
bool canWait
Definition: qthread_p.h:267
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
Sender * currentSender
Definition: qobject_p.h:200
QObjectList children
Definition: qobject.h:93
QThreadData * threadData
Definition: qobject_p.h:195
void deref()
Definition: qthread.cpp:125
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QPostEventList postEventList
Definition: qthread_p.h:266
virtual void wakeUp()=0
Wakes up the event loop.
uint inEventHandler
Definition: qobject.h:102
QEvent * event
Definition: qthread_p.h:78
void ref()
Definition: qthread.cpp:117
QObject * receiver
Definition: qthread_p.h:77
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QAbstractEventDispatcher * eventDispatcher
Definition: qthread_p.h:264

◆ signalIndex()

int QObjectPrivate::signalIndex ( const char *  signalName) const

Returns the signal index used in the internal connectionLists vector.

Warning
This function is not part of the public interface.

It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots.

Definition at line 3719 of file qobject.cpp.

Referenced by QGraphicsScenePrivate::init(), QDeclarativeMouseAreaPrivate::isDoubleClickConnected(), QDeclarativeMouseAreaPrivate::isPressAndHoldConnected(), isSender(), receiverList(), QObject::receivers(), QStateMachinePrivate::registerSignalTransition(), QVariantAnimationPrivate::setCurrentValueForProgress(), and QStateMachinePrivate::unregisterSignalTransition().

3720 {
3721  Q_Q(const QObject);
3722  const QMetaObject *base = q->metaObject();
3723  int relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName, false);
3724  if (relative_index < 0)
3725  relative_index = QMetaObjectPrivate::indexOfSignalRelative(&base, signalName, true);
3726  if (relative_index < 0)
3727  return relative_index;
3728  relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
3729  int signalOffset, methodOffset;
3730  computeOffsets(base, &signalOffset, &methodOffset);
3731  return relative_index + signalOffset;
3732 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int *methodOffset)
Definition: qobject.cpp:225
static int indexOfSignalRelative(const QMetaObject **baseObject, const char *name, bool normalizeStringData)
Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static const uint base
Definition: qurl.cpp:268
#define Q_Q(Class)
Definition: qglobal.h:2483
static int originalClone(const QMetaObject *obj, int local_method_index)

◆ signalSignature()

void QObjectPrivate::signalSignature ( const QMetaMethod signal,
QVarLengthArray< char > *  result 
)
inlinestatic

Definition at line 255 of file qobject_p.h.

Referenced by QDeclarativePropertyPrivate::connect(), QObject::connect(), QDeclarativeNotifierEndpoint::disconnect(), QDeclarativeBoundSignal::disconnect(), and QObject::disconnect().

257 {
258  Q_ASSERT(result);
259  const int signatureLength = qstrlen(signal.signature());
260  if (signatureLength == 0) {
261  result->append((char)0);
262  return;
263  }
264  result->reserve(signatureLength + 2);
265  result->append((char)(QSIGNAL_CODE + '0'));
266  result->append(signal.signature(), signatureLength + 1);
267 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void append(const T &t)
#define QSIGNAL_CODE
Definition: qobjectdefs.h:244
uint qstrlen(const char *str)
Definition: qbytearray.h:79
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
void reserve(int size)

Properties

◆ @37

union { ... }

◆ connectedSignals

quint32 QObjectPrivate::connectedSignals[2]
mutable

Definition at line 201 of file qobject_p.h.

Referenced by QMetaObjectPrivate::connect(), and QObjectPrivate().

◆ connectionLists

QObjectConnectionListVector* QObjectPrivate::connectionLists

◆ currentChildBeingDeleted

QObject* QObjectPrivate::currentChildBeingDeleted

Definition at line 213 of file qobject_p.h.

Referenced by setParent_helper().

◆ currentSender

Sender* QObjectPrivate::currentSender

◆ declarativeData

QAbstractDeclarativeData* QObjectPrivate::declarativeData

◆ eventFilters

QList<QPointer<QObject> > QObjectPrivate::eventFilters

◆ extraData

ExtraData* QObjectPrivate::extraData

◆ objectName

QString QObjectPrivate::objectName

Definition at line 193 of file qobject_p.h.

Referenced by QObject::setObjectName(), and QObjectPrivate::Connection::~Connection().

◆ senders

Connection* QObjectPrivate::senders

◆ sharedRefcount

QAtomicPointer<QtSharedPointer::ExternalRefCountData> QObjectPrivate::sharedRefcount

Definition at line 219 of file qobject_p.h.

Referenced by QObject::~QObject().

◆ threadData

QThreadData* QObjectPrivate::threadData

◆ unused

void* QObjectPrivate::unused

The documentation for this class was generated from the following files: