QObject: remove the undocumented userData() feature

Change-Id: I74445b964eb32bf60f389fcb50bd4929de01230e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2019-06-26 17:41:59 +02:00
parent 49400214e0
commit e125e6837c
4 changed files with 0 additions and 131 deletions

View File

@ -233,10 +233,6 @@ QObjectPrivate::~QObjectPrivate()
if (metaObject) metaObject->objectDestroyed(q_ptr); if (metaObject) metaObject->objectDestroyed(q_ptr);
#ifndef QT_NO_USERDATA
if (extraData)
qDeleteAll(extraData->userData);
#endif
delete extraData; delete extraData;
} }
@ -4188,58 +4184,6 @@ void QObject::dumpObjectInfo() const
} }
} }
#ifndef QT_NO_USERDATA
static QBasicAtomicInteger<uint> 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 #ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QObject *o) QDebug operator<<(QDebug dbg, const QObject *o)

View File

@ -78,12 +78,6 @@ class QRegExp;
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
class QRegularExpression; class QRegularExpression;
#endif #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; struct QDynamicMetaObjectData;
typedef QList<QObject*> QObjectList; typedef QList<QObject*> QObjectList;
@ -408,15 +402,6 @@ public:
QList<QByteArray> dynamicPropertyNames() const; QList<QByteArray> dynamicPropertyNames() const;
#endif // QT_NO_PROPERTIES #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: Q_SIGNALS:
void destroyed(QObject * = nullptr); void destroyed(QObject * = nullptr);
void objectNameChanged(const QString &objectName, QPrivateSignal); 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 inline const QMetaObject *qt_getQtMetaObject() noexcept
{ return &QObject::staticQtMetaObject; } { 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) #if QT_DEPRECATED_SINCE(5, 0)
template<typename T> template<typename T>
inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString())

View File

@ -113,9 +113,6 @@ public:
struct ExtraData struct ExtraData
{ {
ExtraData() {} ExtraData() {}
#ifndef QT_NO_USERDATA
QVector<QObjectUserData *> userData;
#endif
QList<QByteArray> propertyNames; QList<QByteArray> propertyNames;
QVector<QVariant> propertyValues; QVector<QVariant> propertyValues;
QVector<int> runningTimers; QVector<int> runningTimers;

View File

@ -81,9 +81,6 @@ private slots:
void senderTest(); void senderTest();
void declareInterface(); void declareInterface();
void qpointerResetBeforeDestroyedSignal(); void qpointerResetBeforeDestroyedSignal();
#ifndef QT_NO_USERDATA
void testUserData();
#endif
void childDeletesItsSibling(); void childDeletesItsSibling();
void dynamicProperties(); void dynamicProperties();
void floatProperty(); 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; i<USER_DATA_COUNT; ++i) {
user_data_ids[i] = QObject::registerUserData();
}
// Randomize the table a bit
for (int i=0; i<100; ++i) {
int p1 = QRandomGenerator::global()->bounded(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; i<USER_DATA_COUNT; ++i) {
CustomData *data = new CustomData;
data->id = user_data_ids[i];
my_test_object.setUserData(data->id, data);
}
// verify that all ids and positions are matching
for (int i=0; i<USER_DATA_COUNT; ++i) {
int id = user_data_ids[i];
CustomData *data = static_cast<CustomData *>(my_test_object.userData(id));
QVERIFY(data != nullptr);
QCOMPARE(data->id, id);
}
}
#endif // QT_NO_USERDATA
class DestroyedListener : public QObject class DestroyedListener : public QObject
{ {
Q_OBJECT Q_OBJECT