Changeset 561 for trunk/src/corelib/kernel/qobject_p.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/corelib/kernel/qobject_p.h
r2 r561 2 2 ** 3 3 ** 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]) 5 6 ** 6 7 ** This file is part of the QtCore module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you 37 ** @nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 61 61 #include "QtCore/qreadwritelock.h" 62 62 #include "QtCore/qvariant.h" 63 63 64 64 65 QT_BEGIN_NAMESPACE … … 67 68 class QThreadData; 68 69 class QObjectConnectionListVector; 70 69 71 70 72 /* mirrored in QtTestLib, DON'T CHANGE without prior warning */ … … 82 84 extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set; 83 85 84 inline QObjectData::~QObjectData() {}85 86 86 enum { QObjectPrivateVersion = QT_VERSION }; 87 87 88 89 90 91 92 93 94 88 95 class Q_CORE_EXPORT QObjectPrivate : public QObjectData 89 96 { … … 91 98 92 99 public: 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; 103 105 #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 }; 110 131 111 132 struct Sender … … 116 137 }; 117 138 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); 122 148 123 149 bool isSender(const QObject *receiver, const char *signal) const; … … 125 151 QObjectList senderList() const; 126 152 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); 139 159 #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 functions149 struct Connection150 {151 QObject *receiver;152 int method;153 uint connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking154 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);167 160 168 161 static Sender *setCurrentSender(QObject *receiver, … … 173 166 static int *setDeleteWatch(QObjectPrivate *d, int *newWatch); 174 167 static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch); 175 176 int *deleteWatch; 168 static void clearGuards(QObject *); 177 169 178 170 static QObjectPrivate *get(QObject *o) { 179 171 return o->d_func(); 180 172 } 181 }; 173 174 int signalIndex(const char *signalName) const; 175 inline bool isSignalConnected(uint signalIdx) const; 176 177 public: 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 */ 217 inline 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 226 inline 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 245 inline 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 } 182 252 183 253 Q_DECLARE_TYPEINFO(QObjectPrivate::Connection, Q_MOVABLE_TYPE); … … 209 279 }; 210 280 211 class Q _CORE_EXPORT QBoolBlocker281 class QBoolBlocker 212 282 { 213 283 public: … … 221 291 void Q_CORE_EXPORT qDeleteInEventHandler(QObject *o); 222 292 293 294 295 296 297 298 299 300 223 301 QT_END_NAMESPACE 224 302
Note:
See TracChangeset
for help on using the changeset viewer.