QObject: deprecate the undocumented userData() feature

... and schedule it for removal in Qt 6.

This appears to have come to some fame on the internet, so better add
a deprecation warning before we remove it in Qt 6.

Change-Id: I42d91d933f47dfd2d8d54c92358e9e46ced6bf21
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2019-06-26 17:41:59 +02:00
parent 5696260425
commit a27e7e8151
2 changed files with 10 additions and 0 deletions

View File

@ -77,6 +77,9 @@ 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
@ -405,8 +408,11 @@ public:
#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

View File

@ -81,7 +81,9 @@ private slots:
void senderTest();
void declareInterface();
void qpointerResetBeforeDestroyedSignal();
#ifndef QT_NO_USERDATA
void testUserData();
#endif
void childDeletesItsSibling();
void dynamicProperties();
void floatProperty();
@ -2338,6 +2340,7 @@ void tst_QObject::declareInterface()
}
#ifndef QT_NO_USERDATA
class CustomData : public QObjectUserData
{
public:
@ -2380,6 +2383,7 @@ void tst_QObject::testUserData()
QCOMPARE(data->id, id);
}
}
#endif // QT_NO_USERDATA
class DestroyedListener : public QObject
{