Qt 4.8
Public Types | Static Public Functions | Public Variables | List of all members
QMetaObjectPrivate Struct Reference

#include <qmetaobject_p.h>

Public Types

enum  DisconnectType { DisconnectAll, DisconnectOne }
 

Static Public Functions

static bool connect (const QObject *sender, int signal_index, const QObject *receiver, int method_index_relative, const QMetaObject *rmeta=0, int type=0, int *types=0)
 
static bool disconnect (const QObject *sender, int signal_index, const QObject *receiver, int method_index, DisconnectType=DisconnectAll)
 
static bool disconnectHelper (QObjectPrivate::Connection *c, const QObject *receiver, int method_index, QMutex *senderMutex, DisconnectType)
 
static const QMetaObjectPrivateget (const QMetaObject *metaobject)
 
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. More...
 
static int indexOfSlotRelative (const QMetaObject **m, const char *slot, bool normalizeStringData)
 
static void memberIndexes (const QObject *obj, const QMetaMethod &member, int *signalIndex, int *methodIndex)
 This helper function calculates signal and method index for the given member in the specified class. More...
 
static int originalClone (const QMetaObject *obj, int local_method_index)
 

Public Variables

int classInfoCount
 
int classInfoData
 
int className
 
int constructorCount
 
int constructorData
 
int enumeratorCount
 
int enumeratorData
 
int flags
 
int methodCount
 
int methodData
 
int propertyCount
 
int propertyData
 
int revision
 
int signalCount
 

Detailed Description

Definition at line 109 of file qmetaobject_p.h.

Enumerations

◆ DisconnectType

Enumerator
DisconnectAll 
DisconnectOne 

Definition at line 136 of file qmetaobject_p.h.

Functions

◆ connect()

bool QMetaObjectPrivate::connect ( const QObject sender,
int  signal_index,
const QObject receiver,
int  method_index,
const QMetaObject rmeta = 0,
int  type = 0,
int *  types = 0 
)
static
Warning
This function is not part of the public interface. Same as the QMetaObject::connect, but signal_index must be the result of QObjectPrivate::signalIndex

method_index is relative to the rmeta metaobject, if rmeta is null, then it is absolute index

Definition at line 3209 of file qobject.cpp.

Referenced by QObject::connect(), QMetaObject::connect(), and QMetaObject::connectSlotsByName().

3212 {
3213  QObject *s = const_cast<QObject *>(sender);
3214  QObject *r = const_cast<QObject *>(receiver);
3215 
3216  int method_offset = rmeta ? rmeta->methodOffset() : 0;
3218  (rmeta && QMetaObjectPrivate::get(rmeta)->revision >= 6 && rmeta->d.extradata)
3219  ? reinterpret_cast<const QMetaObjectExtraData *>(rmeta->d.extradata)->static_metacall : 0;
3220 
3221  QOrderedMutexLocker locker(signalSlotLock(sender),
3222  signalSlotLock(receiver));
3223 
3224  if (type & Qt::UniqueConnection) {
3226  if (connectionLists && connectionLists->count() > signal_index) {
3227  const QObjectPrivate::Connection *c2 =
3228  (*connectionLists)[signal_index].first;
3229 
3230  int method_index_absolute = method_index + method_offset;
3231 
3232  while (c2) {
3233  if (c2->receiver == receiver && c2->method() == method_index_absolute)
3234  return false;
3235  c2 = c2->nextConnectionList;
3236  }
3237  }
3238  type &= Qt::UniqueConnection - 1;
3239  }
3240 
3242  c->sender = s;
3243  c->receiver = r;
3244  c->method_relative = method_index;
3245  c->method_offset = method_offset;
3246  c->connectionType = type;
3247  c->argumentTypes = types;
3248  c->nextConnectionList = 0;
3249  c->callFunction = callFunction;
3250 
3251  QT_TRY {
3252  QObjectPrivate::get(s)->addConnection(signal_index, c);
3253  } QT_CATCH(...) {
3254  delete c;
3255  QT_RETHROW;
3256  }
3257 
3258  c->prev = &(QObjectPrivate::get(r)->senders);
3259  c->next = *c->prev;
3260  *c->prev = c;
3261  if (c->next)
3262  c->next->prev = &c->next;
3263 
3264  QObjectPrivate *const sender_d = QObjectPrivate::get(s);
3265  if (signal_index < 0) {
3266  sender_d->connectedSignals[0] = sender_d->connectedSignals[1] = ~0;
3267  } else if (signal_index < (int)sizeof(sender_d->connectedSignals) * 8) {
3268  sender_d->connectedSignals[signal_index >> 5] |= (1 << (signal_index & 0x1f));
3269  }
3270 
3271  return true;
3272 }
int type
Definition: qmetatype.cpp:239
unsigned char c[8]
Definition: qnumeric_p.h:62
const void * extradata
Definition: qobjectdefs.h:472
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
Connection * senders
Definition: qobject_p.h:199
void addConnection(int signal, Connection *c)
Definition: qobject.cpp:330
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
#define QT_RETHROW
Definition: qglobal.h:1539
int methodOffset() const
Returns the method offset for this class; i.e.
void(* StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **)
Definition: qobject_p.h:113
QBasicAtomicPointer< int > argumentTypes
Definition: qobject_p.h:124
quint32 connectedSignals[2]
Definition: qobject_p.h:201
#define QT_CATCH(A)
Definition: qglobal.h:1537
static QMutex * signalSlotLock(const QObject *o)
Definition: qobject.cpp:103
Connection * nextConnectionList
Definition: qobject_p.h:120
static const struct @32 types[]
struct QMetaObject::@38 d
static const QMetaObjectPrivate * get(const QMetaObject *metaobject)
StaticMetaCallFunction callFunction
Definition: qobject_p.h:118
#define QT_TRY
Definition: qglobal.h:1536
QObjectConnectionListVector * connectionLists
Definition: qobject_p.h:197

◆ disconnect()

bool QMetaObjectPrivate::disconnect ( const QObject sender,
int  signal_index,
const QObject receiver,
int  method_index,
DisconnectType  disconnectType = DisconnectAll 
)
static
Warning
This function is not part of the public interface. Same as the QMetaObject::disconnect, but signal_index must be the result of QObjectPrivate::signalIndex

Definition at line 3342 of file qobject.cpp.

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

3345 {
3346  if (!sender)
3347  return false;
3348 
3349  QObject *s = const_cast<QObject *>(sender);
3350 
3351  QMutex *senderMutex = signalSlotLock(sender);
3352  QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : 0;
3353  QOrderedMutexLocker locker(senderMutex, receiverMutex);
3354 
3356  if (!connectionLists)
3357  return false;
3358 
3359  // prevent incoming connections changing the connectionLists while unlocked
3360  ++connectionLists->inUse;
3361 
3362  bool success = false;
3363  if (signal_index < 0) {
3364  // remove from all connection lists
3365  for (signal_index = -1; signal_index < connectionLists->count(); ++signal_index) {
3367  (*connectionLists)[signal_index].first;
3368  if (disconnectHelper(c, receiver, method_index, senderMutex, disconnectType)) {
3369  success = true;
3370  connectionLists->dirty = true;
3371  }
3372  }
3373  } else if (signal_index < connectionLists->count()) {
3375  (*connectionLists)[signal_index].first;
3376  if (disconnectHelper(c, receiver, method_index, senderMutex, disconnectType)) {
3377  success = true;
3378  connectionLists->dirty = true;
3379  }
3380  }
3381 
3382  --connectionLists->inUse;
3383  Q_ASSERT(connectionLists->inUse >= 0);
3384  if (connectionLists->orphaned && !connectionLists->inUse)
3385  delete connectionLists;
3386 
3387  return success;
3388 }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
static bool disconnectHelper(QObjectPrivate::Connection *c, const QObject *receiver, int method_index, QMutex *senderMutex, DisconnectType)
Definition: qobject.cpp:3302
static QMutex * signalSlotLock(const QObject *o)
Definition: qobject.cpp:103
QObjectConnectionListVector * connectionLists
Definition: qobject_p.h:197

◆ disconnectHelper()

bool QMetaObjectPrivate::disconnectHelper ( QObjectPrivate::Connection c,
const QObject receiver,
int  method_index,
QMutex senderMutex,
DisconnectType  disconnectType 
)
inlinestatic
Warning
This function is not part of the public interface. Helper function to remove the connection from the senders list and setting the receivers to 0

Definition at line 3302 of file qobject.cpp.

3305 {
3306  bool success = false;
3307  while (c) {
3308  if (c->receiver
3309  && (receiver == 0 || (c->receiver == receiver
3310  && (method_index < 0 || c->method() == method_index)))) {
3311  bool needToUnlock = false;
3312  QMutex *receiverMutex = 0;
3313  if (!receiver) {
3314  receiverMutex = signalSlotLock(c->receiver);
3315  // need to relock this receiver and sender in the correct order
3316  needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex);
3317  }
3318  if (c->receiver) {
3319  *c->prev = c->next;
3320  if (c->next)
3321  c->next->prev = c->prev;
3322  }
3323 
3324  if (needToUnlock)
3325  receiverMutex->unlockInline();
3326 
3327  c->receiver = 0;
3328 
3329  success = true;
3330 
3331  if (disconnectType == DisconnectOne)
3332  return success;
3333  }
3334  c = c->nextConnectionList;
3335  }
3336  return success;
3337 }
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
void unlockInline()
Definition: qmutex.h:196
static QMutex * signalSlotLock(const QObject *o)
Definition: qobject.cpp:103
Connection * nextConnectionList
Definition: qobject_p.h:120

◆ get()

static const QMetaObjectPrivate* QMetaObjectPrivate::get ( const QMetaObject metaobject)
inlinestatic

Definition at line 123 of file qmetaobject_p.h.

Referenced by computeOffsets(), connect(), and QMetaMethod::invoke().

124  { return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
const uint * data
Definition: qobjectdefs.h:471
struct QMetaObject::@38 d

◆ indexOfSignalRelative()

int QMetaObjectPrivate::indexOfSignalRelative ( const QMetaObject **  baseObject,
const char *  signal,
bool  normalizeStringData 
)
static

Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object.

Warning
This function is not part of the public interface.

baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found

Definition at line 648 of file qmetaobject.cpp.

Referenced by QObject::connect(), QObject::disconnect(), get(), QMetaObject::indexOfSignal(), and QObjectPrivate::signalIndex().

651 {
652  int i = indexOfMethodRelative<MethodSignal>(baseObject, signal, normalizeStringData);
653 #ifndef QT_NO_DEBUG
654  const QMetaObject *m = *baseObject;
655  if (i >= 0 && m && m->d.superdata) {
656  int conflict = m->d.superdata->indexOfMethod(signal);
657  if (conflict >= 0)
658  qWarning("QMetaObject::indexOfSignal: signal %s from %s redefined in %s",
659  signal, m->d.superdata->d.stringdata, m->d.stringdata);
660  }
661 #endif
662  return i;
663 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
const QMetaObject * superdata
Definition: qobjectdefs.h:469
struct QMetaObject::@38 d

◆ indexOfSlotRelative()

int QMetaObjectPrivate::indexOfSlotRelative ( const QMetaObject **  m,
const char *  slot,
bool  normalizeStringData 
)
static

Definition at line 685 of file qmetaobject.cpp.

Referenced by QObject::connect(), get(), and QMetaObject::indexOfSlot().

688 {
689  return indexOfMethodRelative<MethodSlot>(m, slot, normalizeStringData);
690 }

◆ memberIndexes()

void QMetaObjectPrivate::memberIndexes ( const QObject obj,
const QMetaMethod member,
int *  signalIndex,
int *  methodIndex 
)
static

This helper function calculates signal and method index for the given member in the specified class.

Warning
This function is not part of the public interface.
  • If member.mobj is 0 then both signalIndex and methodIndex are set to -1.

  • If specified member is not a member of obj instance class (or one of its parent classes) then both signalIndex and methodIndex are set to -1.

This function is used by QObject::connect and QObject::disconnect which are working with QMetaMethod.

signalIndex is set to the signal index of member. If the member specified is not signal this variable is set to -1.

methodIndex is set to the method index of the member. If the member is not a method of the object specified by the obj argument this variable is set to -1.

Definition at line 2468 of file qobject.cpp.

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

2471 {
2472  *signalIndex = -1;
2473  *methodIndex = -1;
2474  if (!obj || !member.mobj)
2475  return;
2476  const QMetaObject *m = obj->metaObject();
2477  // Check that member is member of obj class
2478  while (m != 0 && m != member.mobj)
2479  m = m->d.superdata;
2480  if (!m)
2481  return;
2482  *signalIndex = *methodIndex = (member.handle - get(member.mobj)->methodData)/5;
2483 
2484  int signalOffset;
2485  int methodOffset;
2486  computeOffsets(m, &signalOffset, &methodOffset);
2487 
2488  *methodIndex += methodOffset;
2489  if (member.methodType() == QMetaMethod::Signal) {
2490  *signalIndex = originalClone(m, *signalIndex);
2491  *signalIndex += signalOffset;
2492  } else {
2493  *signalIndex = -1;
2494  }
2495 }
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 originalClone(const QMetaObject *obj, int local_method_index)
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
const QMetaObject * superdata
Definition: qobjectdefs.h:469
struct QMetaObject::@38 d
const QMetaObject * mobj
Definition: qmetaobject.h:139
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ originalClone()

int QMetaObjectPrivate::originalClone ( const QMetaObject mobj,
int  local_method_index 
)
static
Warning
This function is not part of the public interface. If the local_method_index is a cloned method, return the index of the original.

Example: if the index of "destroyed()" is passed, the index of "destroyed(QObject*)" is returned

Definition at line 2883 of file qmetaobject.cpp.

Referenced by QMetaObject::activate(), QObject::connect(), QObject::disconnect(), get(), methodIndexToSignalIndex(), and QObjectPrivate::signalIndex().

2884 {
2885  Q_ASSERT(local_method_index < get(mobj)->methodCount);
2886  int handle = get(mobj)->methodData + 5 * local_method_index;
2887  while (mobj->d.data[handle + 4] & MethodCloned) {
2888  Q_ASSERT(local_method_index > 0);
2889  handle -= 5;
2890  local_method_index--;
2891  }
2892  return local_method_index;
2893 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const uint * data
Definition: qobjectdefs.h:471
struct QMetaObject::@38 d

Properties

◆ classInfoCount

int QMetaObjectPrivate::classInfoCount

◆ classInfoData

int QMetaObjectPrivate::classInfoData

◆ className

int QMetaObjectPrivate::className

Definition at line 112 of file qmetaobject_p.h.

Referenced by buildMetaObject().

◆ constructorCount

int QMetaObjectPrivate::constructorCount

◆ constructorData

int QMetaObjectPrivate::constructorData

◆ enumeratorCount

int QMetaObjectPrivate::enumeratorCount

◆ enumeratorData

int QMetaObjectPrivate::enumeratorData

◆ flags

int QMetaObjectPrivate::flags

◆ methodCount

int QMetaObjectPrivate::methodCount

◆ methodData

int QMetaObjectPrivate::methodData

◆ propertyCount

int QMetaObjectPrivate::propertyCount

◆ propertyData

int QMetaObjectPrivate::propertyData

◆ revision

int QMetaObjectPrivate::revision

◆ signalCount

int QMetaObjectPrivate::signalCount

Definition at line 119 of file qmetaobject_p.h.

Referenced by computeOffsets(), and indexOfMethodRelative().


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