| 1 | // Copyright (C) 2019 The Qt Company Ltd. |
| 2 | // Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com> |
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 | |
| 5 | #ifndef QOBJECT_P_H |
| 6 | #define QOBJECT_P_H |
| 7 | |
| 8 | // |
| 9 | // W A R N I N G |
| 10 | // ------------- |
| 11 | // |
| 12 | // This file is not part of the Qt API. It exists for the convenience |
| 13 | // of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header |
| 14 | // file may change from version to version without notice, or even be removed. |
| 15 | // |
| 16 | // We mean it. |
| 17 | // |
| 18 | |
| 19 | #include <QtCore/private/qglobal_p.h> |
| 20 | #include "QtCore/qcoreevent.h" |
| 21 | #include <QtCore/qfunctionaltools_impl.h> |
| 22 | #include "QtCore/qlist.h" |
| 23 | #include "QtCore/qobject.h" |
| 24 | #include "QtCore/qpointer.h" |
| 25 | #include "QtCore/qvariant.h" |
| 26 | #include "QtCore/qproperty.h" |
| 27 | #include <QtCore/qshareddata.h> |
| 28 | #include "QtCore/private/qproperty_p.h" |
| 29 | |
| 30 | #include <string> |
| 31 | |
| 32 | QT_BEGIN_NAMESPACE |
| 33 | |
| 34 | #ifdef Q_MOC_RUN |
| 35 | #define QT_ANONYMOUS_PROPERTY(text) QT_ANONYMOUS_PROPERTY(text) |
| 36 | #define QT_ANONYMOUS_PRIVATE_PROPERTY(d, text) QT_ANONYMOUS_PRIVATE_PROPERTY(d, text) |
| 37 | #elif !defined QT_NO_META_MACROS |
| 38 | #define QT_ANONYMOUS_PROPERTY(...) QT_ANNOTATE_CLASS(qt_anonymous_property, __VA_ARGS__) |
| 39 | #define QT_ANONYMOUS_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_anonymous_private_property, d, text) |
| 40 | #endif |
| 41 | |
| 42 | class QVariant; |
| 43 | class QThreadData; |
| 44 | class QObjectConnectionListVector; |
| 45 | namespace QtSharedPointer { struct ExternalRefCountData; } |
| 46 | |
| 47 | /* for Qt Test */ |
| 48 | struct QSignalSpyCallbackSet |
| 49 | { |
| 50 | typedef void (*BeginCallback)(QObject *caller, int signal_or_method_index, void **argv); |
| 51 | typedef void (*EndCallback)(QObject *caller, int signal_or_method_index); |
| 52 | BeginCallback signal_begin_callback, |
| 53 | slot_begin_callback; |
| 54 | EndCallback signal_end_callback, |
| 55 | slot_end_callback; |
| 56 | }; |
| 57 | void Q_CORE_EXPORT qt_register_signal_spy_callbacks(QSignalSpyCallbackSet *callback_set); |
| 58 | |
| 59 | extern Q_CORE_EXPORT QBasicAtomicPointer<QSignalSpyCallbackSet> qt_signal_spy_callback_set; |
| 60 | |
| 61 | enum { QObjectPrivateVersion = QT_VERSION }; |
| 62 | |
| 63 | class Q_CORE_EXPORT QAbstractDeclarativeData |
| 64 | { |
| 65 | public: |
| 66 | static void (*destroyed)(QAbstractDeclarativeData *, QObject *); |
| 67 | static void (*signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **); |
| 68 | static int (*receivers)(QAbstractDeclarativeData *, const QObject *, int); |
| 69 | static bool (*isSignalConnected)(QAbstractDeclarativeData *, const QObject *, int); |
| 70 | static void (*setWidgetParent)(QObject *, QObject *); // Used by the QML engine to specify parents for widgets. Set by QtWidgets. |
| 71 | }; |
| 72 | |
| 73 | class Q_CORE_EXPORT QObjectPrivate : public QObjectData |
| 74 | { |
| 75 | public: |
| 76 | Q_DECLARE_PUBLIC(QObject) |
| 77 | |
| 78 | struct |
| 79 | { |
| 80 | (QObjectPrivate *ptr) : parent(ptr) { } |
| 81 | |
| 82 | inline void (const QString &name) |
| 83 | { |
| 84 | parent->q_func()->setObjectName(name); |
| 85 | } |
| 86 | |
| 87 | inline void (const QString &name) |
| 88 | { |
| 89 | Q_EMIT parent->q_func()->objectNameChanged(objectName: name, QObject::QPrivateSignal()); |
| 90 | } |
| 91 | |
| 92 | QList<QByteArray> ; |
| 93 | QList<QVariant> ; |
| 94 | QList<Qt::TimerId> ; |
| 95 | QList<QPointer<QObject>> ; |
| 96 | Q_OBJECT_COMPAT_PROPERTY(QObjectPrivate::ExtraData, QString, , |
| 97 | &QObjectPrivate::ExtraData::setObjectNameForwarder, |
| 98 | &QObjectPrivate::ExtraData::nameChangedForwarder) |
| 99 | QObjectPrivate *; |
| 100 | }; |
| 101 | |
| 102 | void () |
| 103 | { |
| 104 | if (!extraData) |
| 105 | extraData = new ExtraData(this); |
| 106 | } |
| 107 | |
| 108 | typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **); |
| 109 | struct Connection; |
| 110 | struct ConnectionData; |
| 111 | struct ConnectionList; |
| 112 | struct ConnectionOrSignalVector; |
| 113 | struct SignalVector; |
| 114 | struct Sender; |
| 115 | struct TaggedSignalVector; |
| 116 | |
| 117 | /* |
| 118 | This contains the all connections from and to an object. |
| 119 | |
| 120 | The signalVector contains the lists of connections for a given signal. The index in the vector correspond |
| 121 | to the signal index. The signal index is the one returned by QObjectPrivate::signalIndex (not |
| 122 | QMetaObject::indexOfSignal). allsignals contains a list of special connections that will get invoked on |
| 123 | any signal emission. This is done by connecting to signal index -1. |
| 124 | |
| 125 | This vector is protected by the object mutex (signalSlotLock()) |
| 126 | |
| 127 | Each Connection is also part of a 'senders' linked list. This one contains all connections connected |
| 128 | to a slot in this object. The mutex of the receiver must be locked when touching the pointers of this |
| 129 | linked list. |
| 130 | */ |
| 131 | |
| 132 | QObjectPrivate(int version = QObjectPrivateVersion); |
| 133 | virtual ~QObjectPrivate(); |
| 134 | void deleteChildren(); |
| 135 | // used to clear binding storage early in ~QObject |
| 136 | void clearBindingStorage(); |
| 137 | |
| 138 | inline void checkForIncompatibleLibraryVersion(int version) const; |
| 139 | |
| 140 | void setParent_helper(QObject *); |
| 141 | void moveToThread_helper(); |
| 142 | void setThreadData_helper(QThreadData *currentData, QThreadData *targetData, QBindingStatus *status); |
| 143 | |
| 144 | QObjectList receiverList(const char *signal) const; |
| 145 | |
| 146 | inline void ensureConnectionData(); |
| 147 | inline void addConnection(int signal, Connection *c); |
| 148 | static inline bool removeConnection(Connection *c); |
| 149 | |
| 150 | static QObjectPrivate *get(QObject *o) { return o->d_func(); } |
| 151 | static const QObjectPrivate *get(const QObject *o) { return o->d_func(); } |
| 152 | |
| 153 | int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const; |
| 154 | bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const; |
| 155 | bool maybeSignalConnected(uint signalIndex) const; |
| 156 | inline bool isDeclarativeSignalConnected(uint signalIdx) const; |
| 157 | |
| 158 | // To allow abitrary objects to call connectNotify()/disconnectNotify() without making |
| 159 | // the API public in QObject. This is used by QQmlNotifierEndpoint. |
| 160 | inline void connectNotify(const QMetaMethod &signal); |
| 161 | inline void disconnectNotify(const QMetaMethod &signal); |
| 162 | |
| 163 | void reinitBindingStorageAfterThreadMove(); |
| 164 | |
| 165 | template <typename Func1, typename Func2> |
| 166 | static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, |
| 167 | const typename QtPrivate::FunctionPointer<Func2>::Object *receiverPrivate, Func2 slot, |
| 168 | Qt::ConnectionType type = Qt::AutoConnection); |
| 169 | |
| 170 | template <typename Func1, typename Func2> |
| 171 | static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, |
| 172 | const typename QtPrivate::FunctionPointer<Func2>::Object *receiverPrivate, Func2 slot); |
| 173 | |
| 174 | static QMetaObject::Connection connectImpl(const QObject *sender, int signal_index, |
| 175 | const QObject *receiver, void **slot, |
| 176 | QtPrivate::QSlotObjectBase *slotObj, int type, |
| 177 | const int *types, const QMetaObject *senderMetaObject); |
| 178 | static QMetaObject::Connection connect(const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type); |
| 179 | static QMetaObject::Connection connect(const QObject *sender, int signal_index, |
| 180 | const QObject *receiver, |
| 181 | QtPrivate::QSlotObjectBase *slotObj, |
| 182 | Qt::ConnectionType type); |
| 183 | static bool disconnect(const QObject *sender, int signal_index, void **slot); |
| 184 | static bool disconnect(const QObject *sender, int signal_index, const QObject *receiver, |
| 185 | void **slot); |
| 186 | |
| 187 | virtual std::string flagsForDumping() const; |
| 188 | |
| 189 | #ifndef QT_NO_DEBUG_STREAM |
| 190 | virtual void writeToDebugStream(QDebug &) const; |
| 191 | #endif |
| 192 | |
| 193 | QtPrivate::QPropertyAdaptorSlotObject * |
| 194 | getPropertyAdaptorSlotObject(const QMetaProperty &property); |
| 195 | |
| 196 | public: |
| 197 | mutable ExtraData *; // extra data set by the user |
| 198 | // This atomic requires acquire/release semantics in a few places, |
| 199 | // e.g. QObject::moveToThread must synchronize with QCoreApplication::postEvent, |
| 200 | // because postEvent is thread-safe. |
| 201 | // However, most of the code paths involving QObject are only reentrant and |
| 202 | // not thread-safe, so synchronization should not be necessary there. |
| 203 | QAtomicPointer<QThreadData> threadData; // id of the thread that owns the object |
| 204 | |
| 205 | using ConnectionDataPointer = QExplicitlySharedDataPointer<ConnectionData>; |
| 206 | QAtomicPointer<ConnectionData> connections; |
| 207 | |
| 208 | union { |
| 209 | QObject *currentChildBeingDeleted; // should only be used when QObjectData::isDeletingChildren is set |
| 210 | QAbstractDeclarativeData *declarativeData; //extra data used by the declarative module |
| 211 | }; |
| 212 | |
| 213 | // these objects are all used to indicate that a QObject was deleted |
| 214 | // plus QPointer, which keeps a separate list |
| 215 | QAtomicPointer<QtSharedPointer::ExternalRefCountData> sharedRefcount; |
| 216 | }; |
| 217 | |
| 218 | /* |
| 219 | Catch mixing of incompatible library versions. |
| 220 | |
| 221 | Should be called from the constructor of every non-final subclass |
| 222 | of QObjectPrivate, to ensure we catch incompatibilities between |
| 223 | the intermediate base and subclasses thereof. |
| 224 | */ |
| 225 | inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) const |
| 226 | { |
| 227 | #if defined(QT_BUILD_INTERNAL) |
| 228 | // Don't check the version parameter in internal builds. |
| 229 | // This allows incompatible versions to be loaded, possibly for testing. |
| 230 | Q_UNUSED(version); |
| 231 | #else |
| 232 | if (Q_UNLIKELY(version != QObjectPrivateVersion)) { |
| 233 | qFatal("Cannot mix incompatible Qt library (%d.%d.%d) with this library (%d.%d.%d)" , |
| 234 | (version >> 16) & 0xff, (version >> 8) & 0xff, version & 0xff, |
| 235 | (QObjectPrivateVersion >> 16) & 0xff, (QObjectPrivateVersion >> 8) & 0xff, QObjectPrivateVersion & 0xff); |
| 236 | } |
| 237 | #endif |
| 238 | } |
| 239 | |
| 240 | inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const |
| 241 | { |
| 242 | return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected |
| 243 | && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index); |
| 244 | } |
| 245 | |
| 246 | inline void QObjectPrivate::connectNotify(const QMetaMethod &signal) |
| 247 | { |
| 248 | q_ptr->connectNotify(signal); |
| 249 | } |
| 250 | |
| 251 | inline void QObjectPrivate::disconnectNotify(const QMetaMethod &signal) |
| 252 | { |
| 253 | q_ptr->disconnectNotify(signal); |
| 254 | } |
| 255 | |
| 256 | namespace QtPrivate { |
| 257 | inline const QObject *getQObject(const QObjectPrivate *d) { return d->q_func(); } |
| 258 | |
| 259 | template <typename Func> |
| 260 | using FunctionStorage = QtPrivate::CompactStorage<Func>; |
| 261 | |
| 262 | template <typename ObjPrivate> inline void assertObjectType(QObjectPrivate *d) |
| 263 | { |
| 264 | using Obj = std::remove_pointer_t<decltype(std::declval<ObjPrivate *>()->q_func())>; |
| 265 | assertObjectType<Obj>(d->q_ptr); |
| 266 | } |
| 267 | |
| 268 | template<typename Func, typename Args, typename R> |
| 269 | class QPrivateSlotObject : public QSlotObjectBase, private FunctionStorage<Func> |
| 270 | { |
| 271 | typedef QtPrivate::FunctionPointer<Func> FuncType; |
| 272 | #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) |
| 273 | static void impl(int which, QSlotObjectBase *this_, QObject *r, void **a, bool *ret) |
| 274 | #else |
| 275 | static void impl(QSlotObjectBase *this_, QObject *r, void **a, int which, bool *ret) |
| 276 | #endif |
| 277 | { |
| 278 | const auto that = static_cast<QPrivateSlotObject*>(this_); |
| 279 | switch (which) { |
| 280 | case Destroy: |
| 281 | delete that; |
| 282 | break; |
| 283 | case Call: |
| 284 | FuncType::template call<Args, R>(that->object(), |
| 285 | static_cast<typename FuncType::Object *>(QObjectPrivate::get(o: r)), a); |
| 286 | break; |
| 287 | case Compare: |
| 288 | *ret = *reinterpret_cast<Func *>(a) == that->object(); |
| 289 | break; |
| 290 | case NumOperations: ; |
| 291 | } |
| 292 | } |
| 293 | public: |
| 294 | explicit QPrivateSlotObject(Func f) : QSlotObjectBase(&impl), FunctionStorage<Func>{std::move(f)} {} |
| 295 | }; |
| 296 | } //namespace QtPrivate |
| 297 | |
| 298 | template <typename Func1, typename Func2> |
| 299 | inline QMetaObject::Connection QObjectPrivate::connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, |
| 300 | const typename QtPrivate::FunctionPointer<Func2>::Object *receiverPrivate, Func2 slot, |
| 301 | Qt::ConnectionType type) |
| 302 | { |
| 303 | typedef QtPrivate::FunctionPointer<Func1> SignalType; |
| 304 | typedef QtPrivate::FunctionPointer<Func2> SlotType; |
| 305 | static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, |
| 306 | "No Q_OBJECT in the class with the signal" ); |
| 307 | |
| 308 | //compilation error if the arguments does not match. |
| 309 | static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), |
| 310 | "The slot requires more arguments than the signal provides." ); |
| 311 | static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), |
| 312 | "Signal and slot arguments are not compatible." ); |
| 313 | static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), |
| 314 | "Return type of the slot is not compatible with the return type of the signal." ); |
| 315 | |
| 316 | const int *types = nullptr; |
| 317 | if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) |
| 318 | types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types(); |
| 319 | |
| 320 | return QObject::connectImpl(sender, signal: reinterpret_cast<void **>(&signal), |
| 321 | receiver: QtPrivate::getQObject(d: receiverPrivate), slotPtr: reinterpret_cast<void **>(&slot), |
| 322 | slot: new QtPrivate::QPrivateSlotObject<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value, |
| 323 | typename SignalType::ReturnType>(slot), |
| 324 | type, types, senderMetaObject: &SignalType::Object::staticMetaObject); |
| 325 | } |
| 326 | |
| 327 | template <typename Func1, typename Func2> |
| 328 | bool QObjectPrivate::disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object* sender, Func1 signal, |
| 329 | const typename QtPrivate::FunctionPointer< Func2 >::Object* receiverPrivate, Func2 slot) |
| 330 | { |
| 331 | typedef QtPrivate::FunctionPointer<Func1> SignalType; |
| 332 | typedef QtPrivate::FunctionPointer<Func2> SlotType; |
| 333 | static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, |
| 334 | "No Q_OBJECT in the class with the signal" ); |
| 335 | //compilation error if the arguments does not match. |
| 336 | static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), |
| 337 | "Signal and slot arguments are not compatible." ); |
| 338 | return QObject::disconnectImpl(sender, signal: reinterpret_cast<void **>(&signal), |
| 339 | receiver: receiverPrivate->q_ptr, slot: reinterpret_cast<void **>(&slot), |
| 340 | senderMetaObject: &SignalType::Object::staticMetaObject); |
| 341 | } |
| 342 | |
| 343 | class QSemaphore; |
| 344 | class Q_CORE_EXPORT QAbstractMetaCallEvent : public QEvent |
| 345 | { |
| 346 | public: |
| 347 | QAbstractMetaCallEvent(const QObject *sender, int signalId, QSemaphore *semaphore = nullptr) |
| 348 | : QEvent(MetaCall), signalId_(signalId), sender_(sender) |
| 349 | #if QT_CONFIG(thread) |
| 350 | , semaphore_(semaphore) |
| 351 | #endif |
| 352 | { Q_UNUSED(semaphore); } |
| 353 | ~QAbstractMetaCallEvent(); |
| 354 | |
| 355 | virtual void placeMetaCall(QObject *object) = 0; |
| 356 | |
| 357 | inline const QObject *sender() const { return sender_; } |
| 358 | inline int signalId() const { return signalId_; } |
| 359 | |
| 360 | private: |
| 361 | int signalId_; |
| 362 | const QObject *sender_; |
| 363 | #if QT_CONFIG(thread) |
| 364 | QSemaphore *semaphore_; |
| 365 | #endif |
| 366 | }; |
| 367 | |
| 368 | class Q_CORE_EXPORT QMetaCallEvent : public QAbstractMetaCallEvent |
| 369 | { |
| 370 | public: |
| 371 | // blocking queued with semaphore - args always owned by caller |
| 372 | QMetaCallEvent(ushort method_offset, ushort method_relative, |
| 373 | QObjectPrivate::StaticMetaCallFunction callFunction, |
| 374 | const QObject *sender, int signalId, |
| 375 | void **args, QSemaphore *semaphore); |
| 376 | QMetaCallEvent(QtPrivate::QSlotObjectBase *slotObj, |
| 377 | const QObject *sender, int signalId, |
| 378 | void **args, QSemaphore *semaphore); |
| 379 | QMetaCallEvent(QtPrivate::SlotObjUniquePtr slotObj, |
| 380 | const QObject *sender, int signalId, |
| 381 | void **args, QSemaphore *semaphore); |
| 382 | |
| 383 | // queued - args allocated by event, copied by caller |
| 384 | QMetaCallEvent(ushort method_offset, ushort method_relative, |
| 385 | QObjectPrivate::StaticMetaCallFunction callFunction, |
| 386 | const QObject *sender, int signalId, |
| 387 | int nargs); |
| 388 | QMetaCallEvent(QtPrivate::QSlotObjectBase *slotObj, |
| 389 | const QObject *sender, int signalId, |
| 390 | int nargs); |
| 391 | QMetaCallEvent(QtPrivate::SlotObjUniquePtr slotObj, |
| 392 | const QObject *sender, int signalId, |
| 393 | int nargs); |
| 394 | |
| 395 | ~QMetaCallEvent() override; |
| 396 | |
| 397 | template<typename ...Args> |
| 398 | static QMetaCallEvent *create(QtPrivate::QSlotObjectBase *slotObj, const QObject *sender, |
| 399 | int signal_index, const Args &...argv) |
| 400 | { |
| 401 | const void* const argp[] = { nullptr, std::addressof(argv)... }; |
| 402 | const QMetaType metaTypes[] = { QMetaType::fromType<void>(), QMetaType::fromType<Args>()... }; |
| 403 | constexpr auto argc = sizeof...(Args) + 1; |
| 404 | return create_impl(slotObj, sender, signal_index, argc, argp, metaTypes); |
| 405 | } |
| 406 | template<typename ...Args> |
| 407 | static QMetaCallEvent *create(QtPrivate::SlotObjUniquePtr slotObj, const QObject *sender, |
| 408 | int signal_index, const Args &...argv) |
| 409 | { |
| 410 | const void* const argp[] = { nullptr, std::addressof(argv)... }; |
| 411 | const QMetaType metaTypes[] = { QMetaType::fromType<void>(), QMetaType::fromType<Args>()... }; |
| 412 | constexpr auto argc = sizeof...(Args) + 1; |
| 413 | return create_impl(std::move(slotObj), sender, signal_index, argc, argp, metaTypes); |
| 414 | } |
| 415 | |
| 416 | inline int id() const { return d.method_offset_ + d.method_relative_; } |
| 417 | inline const void * const* args() const { return d.args_; } |
| 418 | inline void ** args() { return d.args_; } |
| 419 | inline const QMetaType *types() const { return reinterpret_cast<QMetaType *>(d.args_ + d.nargs_); } |
| 420 | inline QMetaType *types() { return reinterpret_cast<QMetaType *>(d.args_ + d.nargs_); } |
| 421 | |
| 422 | virtual void placeMetaCall(QObject *object) override; |
| 423 | |
| 424 | private: |
| 425 | static QMetaCallEvent *create_impl(QtPrivate::QSlotObjectBase *slotObj, const QObject *sender, |
| 426 | int signal_index, size_t argc, const void * const argp[], |
| 427 | const QMetaType metaTypes[]) |
| 428 | { |
| 429 | if (slotObj) |
| 430 | slotObj->ref(); |
| 431 | return create_impl(slotObj: QtPrivate::SlotObjUniquePtr{slotObj}, sender, |
| 432 | signal_index, argc, argp, metaTypes); |
| 433 | } |
| 434 | static QMetaCallEvent *create_impl(QtPrivate::SlotObjUniquePtr slotObj, const QObject *sender, |
| 435 | int signal_index, size_t argc, const void * const argp[], |
| 436 | const QMetaType metaTypes[]); |
| 437 | inline void allocArgs(); |
| 438 | |
| 439 | struct Data { |
| 440 | QtPrivate::SlotObjUniquePtr slotObj_; |
| 441 | void **args_; |
| 442 | QObjectPrivate::StaticMetaCallFunction callFunction_; |
| 443 | int nargs_; |
| 444 | ushort method_offset_; |
| 445 | ushort method_relative_; |
| 446 | } d; |
| 447 | // preallocate enough space for three arguments |
| 448 | alignas(void *) char prealloc_[3 * sizeof(void *) + 3 * sizeof(QMetaType)]; |
| 449 | }; |
| 450 | |
| 451 | class QBoolBlocker |
| 452 | { |
| 453 | Q_DISABLE_COPY_MOVE(QBoolBlocker) |
| 454 | public: |
| 455 | Q_NODISCARD_CTOR explicit QBoolBlocker(bool &b, bool value = true) |
| 456 | : block(b), reset(b) |
| 457 | { block = value; } |
| 458 | inline ~QBoolBlocker() { block = reset; } |
| 459 | |
| 460 | private: |
| 461 | bool █ |
| 462 | bool reset; |
| 463 | }; |
| 464 | |
| 465 | struct QAbstractDynamicMetaObject; |
| 466 | struct Q_CORE_EXPORT QDynamicMetaObjectData |
| 467 | { |
| 468 | virtual ~QDynamicMetaObjectData(); |
| 469 | virtual void objectDestroyed(QObject *) { delete this; } |
| 470 | |
| 471 | virtual QMetaObject *toDynamicMetaObject(QObject *) = 0; |
| 472 | virtual int metaCall(QObject *, QMetaObject::Call, int _id, void **) = 0; |
| 473 | }; |
| 474 | |
| 475 | struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData, public QMetaObject |
| 476 | { |
| 477 | ~QAbstractDynamicMetaObject(); |
| 478 | |
| 479 | QMetaObject *toDynamicMetaObject(QObject *) override { return this; } |
| 480 | virtual int createProperty(const char *, const char *) { return -1; } |
| 481 | int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) override |
| 482 | { return metaCall(c, _id, a); } |
| 483 | virtual int metaCall(QMetaObject::Call, int _id, void **) { return _id; } // Compat overload |
| 484 | }; |
| 485 | |
| 486 | inline const QBindingStorage *qGetBindingStorage(const QObjectPrivate *o) |
| 487 | { |
| 488 | return &o->bindingStorage; |
| 489 | } |
| 490 | inline QBindingStorage *qGetBindingStorage(QObjectPrivate *o) |
| 491 | { |
| 492 | return &o->bindingStorage; |
| 493 | } |
| 494 | inline const QBindingStorage *(const QObjectPrivate::ExtraData *ed) |
| 495 | { |
| 496 | return &ed->parent->bindingStorage; |
| 497 | } |
| 498 | inline QBindingStorage *(QObjectPrivate::ExtraData *ed) |
| 499 | { |
| 500 | return &ed->parent->bindingStorage; |
| 501 | } |
| 502 | |
| 503 | QT_END_NAMESPACE |
| 504 | |
| 505 | #endif // QOBJECT_P_H |
| 506 | |