From e125e6837cf9a85506206fbef6a7aa716ebcb559 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 17:41:59 +0200 Subject: [PATCH] QObject: remove the undocumented userData() feature Change-Id: I74445b964eb32bf60f389fcb50bd4929de01230e Reviewed-by: Lars Knoll --- src/corelib/kernel/qobject.cpp | 56 ------------------- src/corelib/kernel/qobject.h | 24 -------- src/corelib/kernel/qobject_p.h | 3 - .../corelib/kernel/qobject/tst_qobject.cpp | 48 ---------------- 4 files changed, 131 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index d364ae1087..d6e8ced665 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -233,10 +233,6 @@ QObjectPrivate::~QObjectPrivate() if (metaObject) metaObject->objectDestroyed(q_ptr); -#ifndef QT_NO_USERDATA - if (extraData) - qDeleteAll(extraData->userData); -#endif delete extraData; } @@ -4188,58 +4184,6 @@ void QObject::dumpObjectInfo() const } } -#ifndef QT_NO_USERDATA -static QBasicAtomicInteger user_data_registration = Q_BASIC_ATOMIC_INITIALIZER(0); - -/*! - \internal - */ -uint QObject::registerUserData() -{ - return user_data_registration.fetchAndAddRelaxed(1); -} - -/*! - \fn QObjectUserData::QObjectUserData() - \internal - */ - -/*! - \internal - */ -QObjectUserData::~QObjectUserData() -{ -} - -/*! - \internal - */ -void QObject::setUserData(uint id, QObjectUserData* data) -{ - Q_D(QObject); - if (!d->extraData) - d->extraData = new QObjectPrivate::ExtraData; - - if (d->extraData->userData.size() <= (int) id) - d->extraData->userData.resize((int) id + 1); - d->extraData->userData[id] = data; -} - -/*! - \internal - */ -QObjectUserData* QObject::userData(uint id) const -{ - Q_D(const QObject); - if (!d->extraData) - return 0; - if ((int)id < d->extraData->userData.size()) - return d->extraData->userData.at(id); - return 0; -} - -#endif // QT_NO_USERDATA - #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QObject *o) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 540b8b32c1..296552c2f2 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -78,12 +78,6 @@ class QRegExp; #if QT_CONFIG(regularexpression) class QRegularExpression; #endif -#if !QT_DEPRECATED_SINCE(5, 14) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -# define QT_NO_USERDATA -#endif -#ifndef QT_NO_USERDATA -class QObjectUserData; -#endif struct QDynamicMetaObjectData; typedef QList QObjectList; @@ -408,15 +402,6 @@ public: QList dynamicPropertyNames() const; #endif // QT_NO_PROPERTIES -#ifndef QT_NO_USERDATA - QT_DEPRECATED_VERSION_5_14 - static uint registerUserData(); - QT_DEPRECATED_VERSION_X_5_14("Use setProperty()") - void setUserData(uint id, QObjectUserData* data); - QT_DEPRECATED_VERSION_X_5_14("Use property()") - QObjectUserData* userData(uint id) const; -#endif // QT_NO_USERDATA - Q_SIGNALS: void destroyed(QObject * = nullptr); void objectNameChanged(const QString &objectName, QPrivateSignal); @@ -485,15 +470,6 @@ inline QMetaObject::Connection QObject::connect(const QObject *asender, const ch inline const QMetaObject *qt_getQtMetaObject() noexcept { return &QObject::staticQtMetaObject; } -#ifndef QT_NO_USERDATA -class Q_CORE_EXPORT QObjectUserData { - Q_DISABLE_COPY(QObjectUserData) -public: - QObjectUserData() = default; - virtual ~QObjectUserData(); -}; -#endif - #if QT_DEPRECATED_SINCE(5, 0) template inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 95ffc1b2e8..393d57b20a 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -113,9 +113,6 @@ public: struct ExtraData { ExtraData() {} - #ifndef QT_NO_USERDATA - QVector userData; - #endif QList propertyNames; QVector propertyValues; QVector runningTimers; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index a805bfb747..676999a08c 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -81,9 +81,6 @@ private slots: void senderTest(); void declareInterface(); void qpointerResetBeforeDestroyedSignal(); -#ifndef QT_NO_USERDATA - void testUserData(); -#endif void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); @@ -2341,51 +2338,6 @@ void tst_QObject::declareInterface() } -#ifndef QT_NO_USERDATA -class CustomData : public QObjectUserData -{ -public: - int id; -}; - -void tst_QObject::testUserData() -{ - const int USER_DATA_COUNT = 100; - int user_data_ids[USER_DATA_COUNT]; - - // Register a few - for (int i=0; ibounded(USER_DATA_COUNT); - int p2 = QRandomGenerator::global()->bounded(USER_DATA_COUNT); - - int tmp = user_data_ids[p1]; - user_data_ids[p1] = user_data_ids[p2]; - user_data_ids[p2] = tmp; - } - - // insert the user data into an object - QObject my_test_object; - for (int i=0; iid = user_data_ids[i]; - my_test_object.setUserData(data->id, data); - } - - // verify that all ids and positions are matching - for (int i=0; i(my_test_object.userData(id)); - QVERIFY(data != nullptr); - QCOMPARE(data->id, id); - } -} -#endif // QT_NO_USERDATA - class DestroyedListener : public QObject { Q_OBJECT