Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/kernel/qobject_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information ([email protected])
     4** All rights reserved.
     5** Contact: Nokia Corporation ([email protected])
    56**
    67** This file is part of the QtCore module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you
     37** @nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6161#include "QtCore/qreadwritelock.h"
    6262#include "QtCore/qvariant.h"
     63
    6364
    6465QT_BEGIN_NAMESPACE
     
    6768class QThreadData;
    6869class QObjectConnectionListVector;
     70
    6971
    7072/* mirrored in QtTestLib, DON'T CHANGE without prior warning */
     
    8284extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set;
    8385
    84 inline QObjectData::~QObjectData() {}
    85 
    8686enum { QObjectPrivateVersion = QT_VERSION };
    8787
     88
     89
     90
     91
     92
     93
     94
    8895class Q_CORE_EXPORT QObjectPrivate : public QObjectData
    8996{
     
    9198
    9299public:
    93     QObjectPrivate(int version = QObjectPrivateVersion);
    94     virtual ~QObjectPrivate();
    95 
    96 #ifdef QT3_SUPPORT
    97     QList<QObject *> pendingChildInsertedEvents;
    98     void sendPendingChildInsertedEvents();
    99     void removePendingChildInsertedEvents(QObject *child);
    100 #else
    101     // preserve binary compatibility with code compiled without Qt 3 support
    102     QList<QObject *> unused;
     100    struct ExtraData
     101    {
     102        ExtraData() : objectGuards(0) {}
     103#ifndef QT_NO_USERDATA
     104        QVector<QObjectUserData *> userData;
    103105#endif
    104 
    105     // id of the thread that owns the object
    106     QThreadData *threadData;
    107     void moveToThread_helper();
    108     void setThreadData_helper(QThreadData *currentData, QThreadData *targetData);
    109     void _q_reregisterTimers(void *pointer);
     106        QList<QByteArray> propertyNames;
     107        QList<QVariant> propertyValues;
     108        QGuard<QObject> *objectGuards; //linked list handle of QGuards
     109    };
     110
     111    struct Connection
     112    {
     113        QObject *sender;
     114        QObject *receiver;
     115        int method;
     116        uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
     117        QBasicAtomicPointer<int> argumentTypes;
     118        // The next pointer for the singly-linked ConnectionList
     119        Connection *nextConnectionList;
     120        //senders linked list
     121        Connection *next;
     122        Connection **prev;
     123        ~Connection();
     124    };
     125    // ConnectionList is a singly-linked list
     126    struct ConnectionList {
     127        ConnectionList() : first(0), last(0) {}
     128        Connection *first;
     129        Connection *last;
     130    };
    110131
    111132    struct Sender
     
    116137    };
    117138
    118     // object currently activating the object
    119     Sender *currentSender;
    120 
    121     QObject *currentChildBeingDeleted;
     139
     140    QObjectPrivate(int version = QObjectPrivateVersion);
     141    virtual ~QObjectPrivate();
     142    void deleteChildren();
     143
     144    void setParent_helper(QObject *);
     145    void moveToThread_helper();
     146    void setThreadData_helper(QThreadData *currentData, QThreadData *targetData);
     147    void _q_reregisterTimers(void *pointer);
    122148
    123149    bool isSender(const QObject *receiver, const char *signal) const;
     
    125151    QObjectList senderList() const;
    126152
    127     QList<QPointer<QObject> > eventFilters;
    128 
    129     void setParent_helper(QObject *);
    130 
    131     void deleteChildren();
    132 
    133     static void clearGuards(QObject *);
    134 
    135     struct ExtraData
    136     {
    137 #ifndef QT_NO_USERDATA
    138         QVector<QObjectUserData *> userData;
     153    void addConnection(int signal, Connection *c);
     154    void cleanConnectionLists();
     155
     156#ifdef QT3_SUPPORT
     157    void sendPendingChildInsertedEvents();
     158    void removePendingChildInsertedEvents(QObject *child);
    139159#endif
    140         QList<QByteArray> propertyNames;
    141         QList<QVariant> propertyValues;
    142     };
    143     ExtraData *extraData;
    144     mutable quint32 connectedSignals;
    145 
    146     QString objectName;
    147 
    148     // Note: you must hold the signalSlotLock() before accessing the lists below or calling the functions
    149     struct Connection
    150     {
    151         QObject *receiver;
    152         int method;
    153         uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
    154         QBasicAtomicPointer<int> argumentTypes;
    155     };
    156     typedef QList<Connection> ConnectionList;
    157 
    158     QObjectConnectionListVector *connectionLists;
    159     void addConnection(int signal, Connection *c);
    160     void removeReceiver(int signal, QObject *receiver);
    161     void cleanConnectionLists();
    162 
    163     QList<Sender> senders;
    164     void refSender(QObject *sender, int signal);
    165     void derefSender(QObject *sender, int signal);
    166     void removeSender(QObject *sender, int signal);
    167160
    168161    static Sender *setCurrentSender(QObject *receiver,
     
    173166    static int *setDeleteWatch(QObjectPrivate *d, int *newWatch);
    174167    static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch);
    175 
    176     int *deleteWatch;
     168    static void clearGuards(QObject *);
    177169
    178170    static QObjectPrivate *get(QObject *o) {
    179171        return o->d_func();
    180172    }
    181 };
     173
     174    int signalIndex(const char *signalName) const;
     175    inline bool isSignalConnected(uint signalIdx) const;
     176
     177public:
     178    QString objectName;
     179    ExtraData *extraData;    // extra data set by the user
     180    QThreadData *threadData; // id of the thread that owns the object
     181
     182    QObjectConnectionListVector *connectionLists;
     183
     184    Connection *senders;     // linked list of connections connected to this object
     185    Sender *currentSender;   // object currently activating the object
     186    mutable quint32 connectedSignals[2];
     187
     188#ifdef QT3_SUPPORT
     189    QList<QObject *> pendingChildInsertedEvents;
     190#else
     191    // preserve binary compatibility with code compiled without Qt 3 support
     192    // ### why?
     193    QList<QObject *> unused;
     194#endif
     195
     196    QList<QPointer<QObject> > eventFilters;
     197    union {
     198        QObject *currentChildBeingDeleted;
     199        QDeclarativeData *declarativeData; //extra data used by the DeclarativeUI project.
     200    };
     201
     202    // these objects are all used to indicate that a QObject was deleted
     203    // plus QPointer, which keeps a separate list
     204    QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount;
     205    int *deleteWatch;
     206};
     207
     208
     209/*! \internal
     210
     211  Returns true if the signal with index \a signal_index from object \a sender is connected.
     212  Signals with indices above a certain range are always considered connected (see connectedSignals
     213  in QObjectPrivate). If a signal spy is installed, all signals are considered connected.
     214
     215  \a signal_index must be the index returned by QObjectPrivate::signalIndex;
     216*/
     217inline bool QObjectPrivate::isSignalConnected(uint signal_index) const
     218{
     219    return signal_index >= sizeof(connectedSignals) * 8
     220        || qt_signal_spy_callback_set.signal_begin_callback
     221        || qt_signal_spy_callback_set.signal_end_callback
     222        || (connectedSignals[signal_index >> 5] & (1 << (signal_index & 0x1f)));
     223}
     224
     225
     226inline void q_guard_addGuard(QGuard<QObject> *g)
     227{
     228    QObjectPrivate *p = QObjectPrivate::get(g->o);
     229    if (p->wasDeleted) {
     230        qWarning("QGuard: cannot add guard to deleted object");
     231        g->o = 0;
     232        return;
     233    }
     234
     235    if (!p->extraData)
     236        p->extraData = new QObjectPrivate::ExtraData;
     237
     238    g->next = p->extraData->objectGuards;
     239    p->extraData->objectGuards = g;
     240    g->prev = &p->extraData->objectGuards;
     241    if (g->next)
     242        g->next->prev = &g->next;
     243}
     244
     245inline void q_guard_removeGuard(QGuard<QObject> *g)
     246{
     247    if (g->next) g->next->prev = g->prev;
     248    *g->prev = g->next;
     249    g->next = 0;
     250    g->prev = 0;
     251}
    182252
    183253Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE);
     
    209279};
    210280
    211 class Q_CORE_EXPORT QBoolBlocker
     281class QBoolBlocker
    212282{
    213283public:
     
    221291void Q_CORE_EXPORT qDeleteInEventHandler(QObject *o);
    222292
     293
     294
     295
     296
     297
     298
     299
     300
    223301QT_END_NAMESPACE
    224302
Note: See TracChangeset for help on using the changeset viewer.