Rename QMetaType::construct() to create()

create() is symmetric with destroy().

Also rename the internal methods and fields to be
consistent (qDeleteHelper already had the "right"
name, though!).

This change will allow us to use construct() and
destruct() for something else: Placement new-style
allocation (QTBUG-12574).

The old construct() is still kept for now, until
the other repositories have been updated to use
create().

Change-Id: Iceb184af6cffcb0a634359cfc3516c718ba0c2f5
Reviewed-on: http://codereview.qt-project.org/6342
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Kent Hansen 2011-10-06 13:25:58 +02:00 committed by Qt by Nokia
parent 612ac2b8c8
commit e5ce564b1d
14 changed files with 95 additions and 89 deletions

2
dist/changes-5.0.0 vendored
View File

@ -34,6 +34,8 @@ information about a particular change.
- Qt::escape() is deprecated (but can be enabled via - Qt::escape() is deprecated (but can be enabled via
QT_DISABLE_DEPRECATED_BEFORE), use QString::toHtmlEscaped() instead. QT_DISABLE_DEPRECATED_BEFORE), use QString::toHtmlEscaped() instead.
- QMetaType::construct() has been renamed to QMetaType::create().
**************************************************************************** ****************************************************************************
* General * * General *
**************************************************************************** ****************************************************************************

View File

@ -74,7 +74,7 @@ MyStruct s2 = var.value<MyStruct>();
//! [3] //! [3]
int id = QMetaType::type("MyClass"); int id = QMetaType::type("MyClass");
if (id == 0) { if (id == 0) {
void *myClassPtr = QMetaType::construct(id); void *myClassPtr = QMetaType::create(id);
... ...
QMetaType::destroy(id, myClassPtr); QMetaType::destroy(id, myClassPtr);
myClassPtr = 0; myClassPtr = 0;

View File

@ -1667,7 +1667,7 @@ bool QMetaMethod::invoke(QObject *object,
for (int i = 1; i < paramCount; ++i) { for (int i = 1; i < paramCount; ++i) {
types[i] = QMetaType::type(typeNames[i]); types[i] = QMetaType::type(typeNames[i]);
if (types[i]) { if (types[i]) {
args[i] = QMetaType::construct(types[i], param[i]); args[i] = QMetaType::create(types[i], param[i]);
++nargs; ++nargs;
} else if (param[i]) { } else if (param[i]) {
qWarning("QMetaMethod::invoke: Unable to handle unregistered datatype '%s'", qWarning("QMetaMethod::invoke: Unable to handle unregistered datatype '%s'",

View File

@ -331,8 +331,8 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
struct QMetaTypeGuiHelper struct QMetaTypeGuiHelper
{ {
QMetaType::Constructor constr; QMetaType::Creator creator;
QMetaType::Destructor destr; QMetaType::Deleter deleter;
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
QMetaType::SaveOperator saveOp; QMetaType::SaveOperator saveOp;
QMetaType::LoadOperator loadOp; QMetaType::LoadOperator loadOp;
@ -344,15 +344,15 @@ Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper = 0;
class QCustomTypeInfo class QCustomTypeInfo
{ {
public: public:
QCustomTypeInfo() : typeName(), constr(0), destr(0) QCustomTypeInfo() : typeName(), creator(0), deleter(0)
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
, saveOp(0), loadOp(0) , saveOp(0), loadOp(0)
#endif #endif
{} {}
QByteArray typeName; QByteArray typeName;
QMetaType::Constructor constr; QMetaType::Creator creator;
QMetaType::Destructor destr; QMetaType::Deleter deleter;
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
QMetaType::SaveOperator saveOp; QMetaType::SaveOperator saveOp;
QMetaType::LoadOperator loadOp; QMetaType::LoadOperator loadOp;
@ -464,11 +464,11 @@ static int qMetaTypeCustomType_unlocked(const char *typeName, int length)
destructor, and a \a constructor. Returns the type's handle, destructor, and a \a constructor. Returns the type's handle,
or -1 if the type could not be registered. or -1 if the type could not be registered.
*/ */
int QMetaType::registerType(const char *typeName, Destructor destructor, int QMetaType::registerType(const char *typeName, Deleter deleter,
Constructor constructor) Creator creator)
{ {
QVector<QCustomTypeInfo> *ct = customTypes(); QVector<QCustomTypeInfo> *ct = customTypes();
if (!ct || !typeName || !destructor || !constructor) if (!ct || !typeName || !deleter || !creator)
return -1; return -1;
#ifdef QT_NO_QOBJECT #ifdef QT_NO_QOBJECT
@ -487,8 +487,8 @@ int QMetaType::registerType(const char *typeName, Destructor destructor,
if (!idx) { if (!idx) {
QCustomTypeInfo inf; QCustomTypeInfo inf;
inf.typeName = normalizedTypeName; inf.typeName = normalizedTypeName;
inf.constr = constructor; inf.creator = creator;
inf.destr = destructor; inf.deleter = deleter;
inf.alias = -1; inf.alias = -1;
idx = ct->size() + User; idx = ct->size() + User;
ct->append(inf); ct->append(inf);
@ -532,8 +532,8 @@ int QMetaType::registerTypedef(const char* typeName, int aliasId)
QCustomTypeInfo inf; QCustomTypeInfo inf;
inf.typeName = normalizedTypeName; inf.typeName = normalizedTypeName;
inf.alias = aliasId; inf.alias = aliasId;
inf.constr = 0; inf.creator = 0;
inf.destr = 0; inf.deleter = 0;
ct->append(inf); ct->append(inf);
return aliasId; return aliasId;
} }
@ -561,8 +561,8 @@ void QMetaType::unregisterType(const char *typeName)
if (ct->at(v).typeName == typeName) { if (ct->at(v).typeName == typeName) {
QCustomTypeInfo &inf = (*ct)[v]; QCustomTypeInfo &inf = (*ct)[v];
inf.typeName.clear(); inf.typeName.clear();
inf.constr = 0; inf.creator = 0;
inf.destr = 0; inf.deleter = 0;
inf.alias = -1; inf.alias = -1;
} }
} }
@ -1028,7 +1028,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
\sa destroy(), isRegistered(), Type \sa destroy(), isRegistered(), Type
*/ */
void *QMetaType::construct(int type, const void *copy) void *QMetaType::create(int type, const void *copy)
{ {
if (copy) { if (copy) {
switch(type) { switch(type) {
@ -1226,15 +1226,15 @@ void *QMetaType::construct(int type, const void *copy)
} }
} }
Constructor constr = 0; Creator creator = 0;
if (type >= FirstGuiType && type <= LastGuiType) { if (type >= FirstGuiType && type <= LastGuiType) {
if (!qMetaTypeGuiHelper) if (!qMetaTypeGuiHelper)
return 0; return 0;
constr = qMetaTypeGuiHelper[type - FirstGuiType].constr; creator = qMetaTypeGuiHelper[type - FirstGuiType].creator;
} else if (type >= FirstWidgetsType && type <= LastWidgetsType) { } else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
if (!qMetaTypeWidgetsHelper) if (!qMetaTypeWidgetsHelper)
return 0; return 0;
constr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].constr; creator = qMetaTypeWidgetsHelper[type - FirstWidgetsType].creator;
} else { } else {
const QVector<QCustomTypeInfo> * const ct = customTypes(); const QVector<QCustomTypeInfo> * const ct = customTypes();
QReadLocker locker(customTypesLock()); QReadLocker locker(customTypesLock());
@ -1242,16 +1242,16 @@ void *QMetaType::construct(int type, const void *copy)
return 0; return 0;
if (ct->at(type - User).typeName.isEmpty()) if (ct->at(type - User).typeName.isEmpty())
return 0; return 0;
constr = ct->at(type - User).constr; creator = ct->at(type - User).creator;
} }
return constr(copy); return creator(copy);
} }
/*! /*!
Destroys the \a data, assuming it is of the \a type given. Destroys the \a data, assuming it is of the \a type given.
\sa construct(), isRegistered(), Type \sa create(), isRegistered(), Type
*/ */
void QMetaType::destroy(int type, void *data) void QMetaType::destroy(int type, void *data)
{ {
@ -1390,28 +1390,28 @@ void QMetaType::destroy(int type, void *data)
break; break;
default: { default: {
const QVector<QCustomTypeInfo> * const ct = customTypes(); const QVector<QCustomTypeInfo> * const ct = customTypes();
Destructor destr = 0; Deleter deleter = 0;
if (type >= FirstGuiType && type <= LastGuiType) { if (type >= FirstGuiType && type <= LastGuiType) {
Q_ASSERT(qMetaTypeGuiHelper); Q_ASSERT(qMetaTypeGuiHelper);
if (!qMetaTypeGuiHelper) if (!qMetaTypeGuiHelper)
return; return;
destr = qMetaTypeGuiHelper[type - FirstGuiType].destr; deleter = qMetaTypeGuiHelper[type - FirstGuiType].deleter;
} else if (type >= FirstWidgetsType && type <= LastWidgetsType) { } else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
Q_ASSERT(qMetaTypeWidgetsHelper); Q_ASSERT(qMetaTypeWidgetsHelper);
if (!qMetaTypeWidgetsHelper) if (!qMetaTypeWidgetsHelper)
return; return;
destr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].destr; deleter = qMetaTypeWidgetsHelper[type - FirstWidgetsType].deleter;
} else { } else {
QReadLocker locker(customTypesLock()); QReadLocker locker(customTypesLock());
if (type < User || !ct || ct->count() <= type - User) if (type < User || !ct || ct->count() <= type - User)
break; break;
if (ct->at(type - User).typeName.isEmpty()) if (ct->at(type - User).typeName.isEmpty())
break; break;
destr = ct->at(type - User).destr; deleter = ct->at(type - User).deleter;
} }
destr(data); deleter(data);
break; } break; }
} }
} }
@ -1463,10 +1463,10 @@ void QMetaType::destroy(int type, void *data)
\sa qRegisterMetaType(), QMetaType::isRegistered(), Q_DECLARE_METATYPE() \sa qRegisterMetaType(), QMetaType::isRegistered(), Q_DECLARE_METATYPE()
*/ */
/*! \typedef QMetaType::Destructor /*! \typedef QMetaType::Deleter
\internal \internal
*/ */
/*! \typedef QMetaType::Constructor /*! \typedef QMetaType::Creator
\internal \internal
*/ */
/*! \typedef QMetaType::SaveOperator /*! \typedef QMetaType::SaveOperator

View File

@ -103,8 +103,8 @@ public:
User = 256 User = 256
}; };
typedef void (*Destructor)(void *); typedef void (*Deleter)(void *);
typedef void *(*Constructor)(const void *); typedef void *(*Creator)(const void *);
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
typedef void (*SaveOperator)(QDataStream &, const void *); typedef void (*SaveOperator)(QDataStream &, const void *);
@ -114,13 +114,17 @@ public:
static void registerStreamOperators(int type, SaveOperator saveOp, static void registerStreamOperators(int type, SaveOperator saveOp,
LoadOperator loadOp); LoadOperator loadOp);
#endif #endif
static int registerType(const char *typeName, Destructor destructor, static int registerType(const char *typeName, Deleter deleter,
Constructor constructor); Creator creator);
static int registerTypedef(const char *typeName, int aliasId); static int registerTypedef(const char *typeName, int aliasId);
static int type(const char *typeName); static int type(const char *typeName);
static const char *typeName(int type); static const char *typeName(int type);
static bool isRegistered(int type); static bool isRegistered(int type);
static void *construct(int type, const void *copy = 0); static void *create(int type, const void *copy = 0);
#ifdef QT_DEPRECATED
QT_DEPRECATED static void *construct(int type, const void *copy = 0)
{ return create(type, copy); }
#endif
static void destroy(int type, void *data); static void destroy(int type, void *data);
static void unregisterType(const char *typeName); static void unregisterType(const char *typeName);
@ -137,7 +141,7 @@ void qMetaTypeDeleteHelper(T *t)
} }
template <typename T> template <typename T>
void *qMetaTypeConstructHelper(const T *t) void *qMetaTypeCreateHelper(const T *t)
{ {
if (!t) if (!t)
return new T(); return new T();
@ -194,13 +198,13 @@ int qRegisterMetaType(const char *typeName
if (typedefOf != -1) if (typedefOf != -1)
return QMetaType::registerTypedef(typeName, typedefOf); return QMetaType::registerTypedef(typeName, typedefOf);
typedef void*(*ConstructPtr)(const T*); typedef void*(*CreatePtr)(const T*);
ConstructPtr cptr = qMetaTypeConstructHelper<T>; CreatePtr cptr = qMetaTypeCreateHelper<T>;
typedef void(*DeletePtr)(T*); typedef void(*DeletePtr)(T*);
DeletePtr dptr = qMetaTypeDeleteHelper<T>; DeletePtr dptr = qMetaTypeDeleteHelper<T>;
return QMetaType::registerType(typeName, reinterpret_cast<QMetaType::Destructor>(dptr), return QMetaType::registerType(typeName, reinterpret_cast<QMetaType::Deleter>(dptr),
reinterpret_cast<QMetaType::Constructor>(cptr)); reinterpret_cast<QMetaType::Creator>(cptr));
} }
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM

View File

@ -3242,7 +3242,7 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
types[0] = 0; // return type types[0] = 0; // return type
args[0] = 0; // return value args[0] = 0; // return value
for (int n = 1; n < nargs; ++n) for (int n = 1; n < nargs; ++n)
args[n] = QMetaType::construct((types[n] = c->argumentTypes[n-1]), argv[n]); args[n] = QMetaType::create((types[n] = c->argumentTypes[n-1]), argv[n]);
QCoreApplication::postEvent(c->receiver, new QMetaCallEvent(c->method_offset, QCoreApplication::postEvent(c->receiver, new QMetaCallEvent(c->method_offset,
c->method_relative, c->method_relative,
c->callFunction, c->callFunction,

View File

@ -180,7 +180,7 @@ static void construct(QVariant::Private *x, const void *copy)
case QVariant::UserType: case QVariant::UserType:
break; break;
default: default:
void *ptr = QMetaType::construct(x->type, copy); void *ptr = QMetaType::create(x->type, copy);
if (!ptr) { if (!ptr) {
x->type = QVariant::Invalid; x->type = QVariant::Invalid;
} else { } else {

View File

@ -637,8 +637,8 @@ const QVariant::Handler qt_gui_variant_handler = {
struct QMetaTypeGuiHelper struct QMetaTypeGuiHelper
{ {
QMetaType::Constructor constr; QMetaType::Creator creator;
QMetaType::Destructor destr; QMetaType::Deleter deleter;
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
QMetaType::SaveOperator saveOp; QMetaType::SaveOperator saveOp;
QMetaType::LoadOperator loadOp; QMetaType::LoadOperator loadOp;
@ -650,16 +650,16 @@ extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper;
#ifdef QT_NO_DATASTREAM #ifdef QT_NO_DATASTREAM
# define Q_DECL_METATYPE_HELPER(TYPE) \ # define Q_DECL_METATYPE_HELPER(TYPE) \
typedef void *(*QConstruct##TYPE)(const TYPE *); \ typedef void *(*QCreate##TYPE)(const TYPE *); \
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \ static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
typedef void (*QDestruct##TYPE)(TYPE *); \ typedef void (*QDelete##TYPE)(TYPE *); \
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>;
#else #else
# define Q_DECL_METATYPE_HELPER(TYPE) \ # define Q_DECL_METATYPE_HELPER(TYPE) \
typedef void *(*QConstruct##TYPE)(const TYPE *); \ typedef void *(*QCreate##TYPE)(const TYPE *); \
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \ static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
typedef void (*QDestruct##TYPE)(TYPE *); \ typedef void (*QDelete##TYPE)(TYPE *); \
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \ static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \
typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \ typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \ static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \ typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
@ -704,12 +704,12 @@ Q_DECL_METATYPE_HELPER(QQuaternion)
#ifdef QT_NO_DATASTREAM #ifdef QT_NO_DATASTREAM
# define Q_IMPL_METATYPE_HELPER(TYPE) \ # define Q_IMPL_METATYPE_HELPER(TYPE) \
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \ { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) } reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE) }
#else #else
# define Q_IMPL_METATYPE_HELPER(TYPE) \ # define Q_IMPL_METATYPE_HELPER(TYPE) \
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \ { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \ reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \
reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \ reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \ reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
} }

View File

@ -93,7 +93,7 @@ void QTestData::append(int type, const void *data)
d->dataCount, d->tag); d->dataCount, d->tag);
QTEST_ASSERT(false); QTEST_ASSERT(false);
} }
d->data[d->dataCount] = QMetaType::construct(type, data); d->data[d->dataCount] = QMetaType::create(type, data);
++d->dataCount; ++d->dataCount;
} }

View File

@ -135,8 +135,8 @@ static const QVariant::Handler widgets_handler = {
struct QMetaTypeGuiHelper struct QMetaTypeGuiHelper
{ {
QMetaType::Constructor constr; QMetaType::Creator creator;
QMetaType::Destructor destr; QMetaType::Deleter deleter;
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
QMetaType::SaveOperator saveOp; QMetaType::SaveOperator saveOp;
QMetaType::LoadOperator loadOp; QMetaType::LoadOperator loadOp;
@ -148,16 +148,16 @@ extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper;
#ifdef QT_NO_DATASTREAM #ifdef QT_NO_DATASTREAM
# define Q_DECL_METATYPE_HELPER(TYPE) \ # define Q_DECL_METATYPE_HELPER(TYPE) \
typedef void *(*QConstruct##TYPE)(const TYPE *); \ typedef void *(*QCreate##TYPE)(const TYPE *); \
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \ static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
typedef void (*QDestruct##TYPE)(TYPE *); \ typedef void (*QDelete##TYPE)(TYPE *); \
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>;
#else #else
# define Q_DECL_METATYPE_HELPER(TYPE) \ # define Q_DECL_METATYPE_HELPER(TYPE) \
typedef void *(*QConstruct##TYPE)(const TYPE *); \ typedef void *(*QCreate##TYPE)(const TYPE *); \
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \ static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
typedef void (*QDestruct##TYPE)(TYPE *); \ typedef void (*QDelete##TYPE)(TYPE *); \
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \ static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \
typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \ typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \ static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \ typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
@ -171,12 +171,12 @@ Q_DECL_METATYPE_HELPER(QSizePolicy)
#ifdef QT_NO_DATASTREAM #ifdef QT_NO_DATASTREAM
# define Q_IMPL_METATYPE_HELPER(TYPE) \ # define Q_IMPL_METATYPE_HELPER(TYPE) \
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \ { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) } reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE) }
#else #else
# define Q_IMPL_METATYPE_HELPER(TYPE) \ # define Q_IMPL_METATYPE_HELPER(TYPE) \
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \ { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \ reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \
reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \ reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \ reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
} }

View File

@ -72,7 +72,7 @@ private slots:
void normalizedTypes(); void normalizedTypes();
void typeName_data(); void typeName_data();
void typeName(); void typeName();
void construct(); void create();
void typedefs(); void typedefs();
void isRegistered_data(); void isRegistered_data();
void isRegistered(); void isRegistered();
@ -133,15 +133,15 @@ protected:
++failureCount; ++failureCount;
qWarning() << "Wrong typeName returned for" << tp; qWarning() << "Wrong typeName returned for" << tp;
} }
void *buf = QMetaType::construct(tp, 0); void *buf = QMetaType::create(tp, 0);
void *buf2 = QMetaType::construct(tp, buf); void *buf2 = QMetaType::create(tp, buf);
if (!buf) { if (!buf) {
++failureCount; ++failureCount;
qWarning() << "Null buffer returned by QMetaType::construct(tp, 0)"; qWarning() << "Null buffer returned by QMetaType::create(tp, 0)";
} }
if (!buf2) { if (!buf2) {
++failureCount; ++failureCount;
qWarning() << "Null buffer returned by QMetaType::construct(tp, buf)"; qWarning() << "Null buffer returned by QMetaType::create(tp, buf)";
} }
QMetaType::destroy(tp, buf); QMetaType::destroy(tp, buf);
QMetaType::destroy(tp, buf2); QMetaType::destroy(tp, buf2);
@ -268,10 +268,10 @@ void tst_QMetaType::typeName()
QCOMPARE(QString::fromLatin1(QMetaType::typeName(aType)), aTypeName); QCOMPARE(QString::fromLatin1(QMetaType::typeName(aType)), aTypeName);
} }
void tst_QMetaType::construct() void tst_QMetaType::create()
{ {
QSize x(1, 1); QSize x(1, 1);
void *size = QMetaType::construct(QMetaType::QSize, &x); void *size = QMetaType::create(QMetaType::QSize, &x);
QVERIFY(size); QVERIFY(size);
QCOMPARE(static_cast<QSize *>(size)->width(), 1); QCOMPARE(static_cast<QSize *>(size)->width(), 1);
QMetaType::destroy(QMetaType::QSize, size); QMetaType::destroy(QMetaType::QSize, size);

View File

@ -1298,7 +1298,7 @@ void tst_QVariant::matrix()
qVariantSetValue(variant, QMatrix().rotate(90)); qVariantSetValue(variant, QMatrix().rotate(90));
QCOMPARE(QMatrix().rotate(90), qVariantValue<QMatrix>(variant)); QCOMPARE(QMatrix().rotate(90), qVariantValue<QMatrix>(variant));
void *mmatrix = QMetaType::construct(QVariant::Matrix, 0); void *mmatrix = QMetaType::create(QVariant::Matrix, 0);
QVERIFY(mmatrix); QVERIFY(mmatrix);
QMetaType::destroy(QVariant::Matrix, mmatrix); QMetaType::destroy(QVariant::Matrix, mmatrix);
} }
@ -1313,7 +1313,7 @@ void tst_QVariant::matrix4x4()
qVariantSetValue(variant, m); qVariantSetValue(variant, m);
QCOMPARE(m, qVariantValue<QMatrix4x4>(variant)); QCOMPARE(m, qVariantValue<QMatrix4x4>(variant));
void *mmatrix = QMetaType::construct(QVariant::Matrix4x4, 0); void *mmatrix = QMetaType::create(QVariant::Matrix4x4, 0);
QVERIFY(mmatrix); QVERIFY(mmatrix);
QMetaType::destroy(QVariant::Matrix4x4, mmatrix); QMetaType::destroy(QVariant::Matrix4x4, mmatrix);
} }
@ -1326,7 +1326,7 @@ void tst_QVariant::transform()
qVariantSetValue(variant, QTransform().rotate(90)); qVariantSetValue(variant, QTransform().rotate(90));
QCOMPARE(QTransform().rotate(90), qVariantValue<QTransform>(variant)); QCOMPARE(QTransform().rotate(90), qVariantValue<QTransform>(variant));
void *mmatrix = QMetaType::construct(QVariant::Transform, 0); void *mmatrix = QMetaType::create(QVariant::Transform, 0);
QVERIFY(mmatrix); QVERIFY(mmatrix);
QMetaType::destroy(QVariant::Transform, mmatrix); QMetaType::destroy(QVariant::Transform, mmatrix);
} }
@ -1340,7 +1340,7 @@ void tst_QVariant::vector2D()
qVariantSetValue(variant, QVector2D(0.1, 0.2)); qVariantSetValue(variant, QVector2D(0.1, 0.2));
QCOMPARE(QVector2D(0.1, 0.2), qVariantValue<QVector2D>(variant)); QCOMPARE(QVector2D(0.1, 0.2), qVariantValue<QVector2D>(variant));
void *pvector = QMetaType::construct(QVariant::Vector2D, 0); void *pvector = QMetaType::create(QVariant::Vector2D, 0);
QVERIFY(pvector); QVERIFY(pvector);
QMetaType::destroy(QVariant::Vector2D, pvector); QMetaType::destroy(QVariant::Vector2D, pvector);
} }
@ -1353,7 +1353,7 @@ void tst_QVariant::vector3D()
qVariantSetValue(variant, QVector3D(0.1, 0.2, 0.3)); qVariantSetValue(variant, QVector3D(0.1, 0.2, 0.3));
QCOMPARE(QVector3D(0.1, 0.2, 0.3), qVariantValue<QVector3D>(variant)); QCOMPARE(QVector3D(0.1, 0.2, 0.3), qVariantValue<QVector3D>(variant));
void *pvector = QMetaType::construct(QVariant::Vector3D, 0); void *pvector = QMetaType::create(QVariant::Vector3D, 0);
QVERIFY(pvector); QVERIFY(pvector);
QMetaType::destroy(QVariant::Vector3D, pvector); QMetaType::destroy(QVariant::Vector3D, pvector);
} }
@ -1366,7 +1366,7 @@ void tst_QVariant::vector4D()
qVariantSetValue(variant, QVector4D(0.1, 0.2, 0.3, 0.4)); qVariantSetValue(variant, QVector4D(0.1, 0.2, 0.3, 0.4));
QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qVariantValue<QVector4D>(variant)); QCOMPARE(QVector4D(0.1, 0.2, 0.3, 0.4), qVariantValue<QVector4D>(variant));
void *pvector = QMetaType::construct(QVariant::Vector4D, 0); void *pvector = QMetaType::create(QVariant::Vector4D, 0);
QVERIFY(pvector); QVERIFY(pvector);
QMetaType::destroy(QVariant::Vector4D, pvector); QMetaType::destroy(QVariant::Vector4D, pvector);
} }
@ -1379,7 +1379,7 @@ void tst_QVariant::quaternion()
qVariantSetValue(variant, QQuaternion(0.1, 0.2, 0.3, 0.4)); qVariantSetValue(variant, QQuaternion(0.1, 0.2, 0.3, 0.4));
QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qVariantValue<QQuaternion>(variant)); QCOMPARE(QQuaternion(0.1, 0.2, 0.3, 0.4), qVariantValue<QQuaternion>(variant));
void *pquaternion = QMetaType::construct(QVariant::Quaternion, 0); void *pquaternion = QMetaType::create(QVariant::Quaternion, 0);
QVERIFY(pquaternion); QVERIFY(pquaternion);
QMetaType::destroy(QVariant::Quaternion, pquaternion); QMetaType::destroy(QVariant::Quaternion, pquaternion);
} }

View File

@ -253,7 +253,7 @@ void tst_QMetaType::constructCoreType()
QFETCH(int, typeId); QFETCH(int, typeId);
QBENCHMARK { QBENCHMARK {
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 100000; ++i) {
void *data = QMetaType::construct(typeId, (void *)0); void *data = QMetaType::create(typeId, (void *)0);
QMetaType::destroy(typeId, data); QMetaType::destroy(typeId, data);
} }
} }
@ -275,7 +275,7 @@ void tst_QMetaType::constructCoreTypeCopy()
const void *copy = other.constData(); const void *copy = other.constData();
QBENCHMARK { QBENCHMARK {
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 100000; ++i) {
void *data = QMetaType::construct(typeId, copy); void *data = QMetaType::create(typeId, copy);
QMetaType::destroy(typeId, data); QMetaType::destroy(typeId, data);
} }
} }

View File

@ -81,7 +81,7 @@ void tst_QGuiMetaType::constructGuiType()
QFETCH(int, typeId); QFETCH(int, typeId);
QBENCHMARK { QBENCHMARK {
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 100000; ++i) {
void *data = QMetaType::construct(typeId, (void *)0); void *data = QMetaType::create(typeId, (void *)0);
QMetaType::destroy(typeId, data); QMetaType::destroy(typeId, data);
} }
} }
@ -103,7 +103,7 @@ void tst_QGuiMetaType::constructGuiTypeCopy()
const void *copy = other.constData(); const void *copy = other.constData();
QBENCHMARK { QBENCHMARK {
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 100000; ++i) {
void *data = QMetaType::construct(typeId, copy); void *data = QMetaType::create(typeId, copy);
QMetaType::destroy(typeId, data); QMetaType::destroy(typeId, data);
} }
} }