Remove QMetaType::unregisterType().
The function hasn't been working properly. It was not well tested, for example it is undefined how QVariant should behave if it contains an instance of an unregistered type. Concept of unregistering types was inspired by plug-in system, but in most supported platforms we do not unload plug-ins. Idea of type unregistering may block optimizations in meta object system, because it would be not possible to cache a type id. QMetaType::type() could return different ids for the same name. Currently QMetaType::unregisterType() is not used in Qt. Change-Id: I878b6e8d91de99f9bcefeab73af2e2ba0bd0cba0 Reviewed-by: Prasanth Ullattil <prasanth.ullattil@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>bb10
parent
56265031b7
commit
b8cf1d6bdc
|
|
@ -45,7 +45,9 @@ information about a particular change.
|
|||
in Qt4, so these methods return a bool now. If your code used the undocumented
|
||||
QBool, simply replace it with bool.
|
||||
|
||||
- QMetaType::construct() has been renamed to QMetaType::create().
|
||||
- QMetaType:
|
||||
* QMetaType::construct() has been renamed to QMetaType::create().
|
||||
* QMetaType::unregisterType() has been removed.
|
||||
|
||||
- QTestLib:
|
||||
* The QTRY_VERIFY and QTRY_COMPARE macros have been moved into QTestLib.
|
||||
|
|
|
|||
|
|
@ -531,36 +531,6 @@ int QMetaType::registerTypedef(const char* typeName, int aliasId)
|
|||
return aliasId;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.4
|
||||
|
||||
Unregisters a user type, with \a typeName.
|
||||
|
||||
\sa type(), typeName()
|
||||
*/
|
||||
void QMetaType::unregisterType(const char *typeName)
|
||||
{
|
||||
QVector<QCustomTypeInfo> *ct = customTypes();
|
||||
if (!ct || !typeName)
|
||||
return;
|
||||
|
||||
#ifdef QT_NO_QOBJECT
|
||||
NS(QByteArray) normalizedTypeName = typeName;
|
||||
#else
|
||||
NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
|
||||
#endif
|
||||
QWriteLocker locker(customTypesLock());
|
||||
for (int v = 0; v < ct->count(); ++v) {
|
||||
if (ct->at(v).typeName == typeName) {
|
||||
QCustomTypeInfo &inf = (*ct)[v];
|
||||
inf.typeName.clear();
|
||||
inf.creator = 0;
|
||||
inf.deleter = 0;
|
||||
inf.alias = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the datatype with ID \a type is registered;
|
||||
otherwise returns false.
|
||||
|
|
|
|||
|
|
@ -247,7 +247,6 @@ public:
|
|||
static void destroy(int type, void *data);
|
||||
static void *construct(int type, void *where, const void *copy);
|
||||
static void destruct(int type, void *where);
|
||||
static void unregisterType(const char *typeName);
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
static bool save(QDataStream &stream, int type, const void *data);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ private slots:
|
|||
void typedefs();
|
||||
void isRegistered_data();
|
||||
void isRegistered();
|
||||
void unregisterType();
|
||||
void registerStreamBuiltin();
|
||||
void automaticTemplateRegistration();
|
||||
};
|
||||
|
|
@ -857,28 +856,6 @@ void tst_QMetaType::isRegistered()
|
|||
QCOMPARE(QMetaType::isRegistered(typeId), registered);
|
||||
}
|
||||
|
||||
class RegUnreg
|
||||
{
|
||||
public:
|
||||
RegUnreg() {};
|
||||
RegUnreg(const RegUnreg &) {};
|
||||
~RegUnreg() {};
|
||||
};
|
||||
|
||||
void tst_QMetaType::unregisterType()
|
||||
{
|
||||
// cannot unregister standard types
|
||||
int typeId = qRegisterMetaType<QList<QVariant> >("QList<QVariant>");
|
||||
QCOMPARE(QMetaType::isRegistered(typeId), true);
|
||||
QMetaType::unregisterType("QList<QVariant>");
|
||||
QCOMPARE(QMetaType::isRegistered(typeId), true);
|
||||
// allow unregister user types
|
||||
typeId = qRegisterMetaType<RegUnreg>("RegUnreg");
|
||||
QCOMPARE(QMetaType::isRegistered(typeId), true);
|
||||
QMetaType::unregisterType("RegUnreg");
|
||||
QCOMPARE(QMetaType::isRegistered(typeId), false);
|
||||
}
|
||||
|
||||
void tst_QMetaType::registerStreamBuiltin()
|
||||
{
|
||||
//should not crash;
|
||||
|
|
|
|||
Loading…
Reference in New Issue