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:
parent
612ac2b8c8
commit
e5ce564b1d
2
dist/changes-5.0.0
vendored
2
dist/changes-5.0.0
vendored
@ -34,6 +34,8 @@ information about a particular change.
|
||||
- Qt::escape() is deprecated (but can be enabled via
|
||||
QT_DISABLE_DEPRECATED_BEFORE), use QString::toHtmlEscaped() instead.
|
||||
|
||||
- QMetaType::construct() has been renamed to QMetaType::create().
|
||||
|
||||
****************************************************************************
|
||||
* General *
|
||||
****************************************************************************
|
||||
|
@ -74,7 +74,7 @@ MyStruct s2 = var.value<MyStruct>();
|
||||
//! [3]
|
||||
int id = QMetaType::type("MyClass");
|
||||
if (id == 0) {
|
||||
void *myClassPtr = QMetaType::construct(id);
|
||||
void *myClassPtr = QMetaType::create(id);
|
||||
...
|
||||
QMetaType::destroy(id, myClassPtr);
|
||||
myClassPtr = 0;
|
||||
|
@ -1667,7 +1667,7 @@ bool QMetaMethod::invoke(QObject *object,
|
||||
for (int i = 1; i < paramCount; ++i) {
|
||||
types[i] = QMetaType::type(typeNames[i]);
|
||||
if (types[i]) {
|
||||
args[i] = QMetaType::construct(types[i], param[i]);
|
||||
args[i] = QMetaType::create(types[i], param[i]);
|
||||
++nargs;
|
||||
} else if (param[i]) {
|
||||
qWarning("QMetaMethod::invoke: Unable to handle unregistered datatype '%s'",
|
||||
|
@ -331,8 +331,8 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
|
||||
|
||||
struct QMetaTypeGuiHelper
|
||||
{
|
||||
QMetaType::Constructor constr;
|
||||
QMetaType::Destructor destr;
|
||||
QMetaType::Creator creator;
|
||||
QMetaType::Deleter deleter;
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
QMetaType::SaveOperator saveOp;
|
||||
QMetaType::LoadOperator loadOp;
|
||||
@ -344,15 +344,15 @@ Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper = 0;
|
||||
class QCustomTypeInfo
|
||||
{
|
||||
public:
|
||||
QCustomTypeInfo() : typeName(), constr(0), destr(0)
|
||||
QCustomTypeInfo() : typeName(), creator(0), deleter(0)
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
, saveOp(0), loadOp(0)
|
||||
#endif
|
||||
{}
|
||||
|
||||
QByteArray typeName;
|
||||
QMetaType::Constructor constr;
|
||||
QMetaType::Destructor destr;
|
||||
QMetaType::Creator creator;
|
||||
QMetaType::Deleter deleter;
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
QMetaType::SaveOperator saveOp;
|
||||
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,
|
||||
or -1 if the type could not be registered.
|
||||
*/
|
||||
int QMetaType::registerType(const char *typeName, Destructor destructor,
|
||||
Constructor constructor)
|
||||
int QMetaType::registerType(const char *typeName, Deleter deleter,
|
||||
Creator creator)
|
||||
{
|
||||
QVector<QCustomTypeInfo> *ct = customTypes();
|
||||
if (!ct || !typeName || !destructor || !constructor)
|
||||
if (!ct || !typeName || !deleter || !creator)
|
||||
return -1;
|
||||
|
||||
#ifdef QT_NO_QOBJECT
|
||||
@ -487,8 +487,8 @@ int QMetaType::registerType(const char *typeName, Destructor destructor,
|
||||
if (!idx) {
|
||||
QCustomTypeInfo inf;
|
||||
inf.typeName = normalizedTypeName;
|
||||
inf.constr = constructor;
|
||||
inf.destr = destructor;
|
||||
inf.creator = creator;
|
||||
inf.deleter = deleter;
|
||||
inf.alias = -1;
|
||||
idx = ct->size() + User;
|
||||
ct->append(inf);
|
||||
@ -532,8 +532,8 @@ int QMetaType::registerTypedef(const char* typeName, int aliasId)
|
||||
QCustomTypeInfo inf;
|
||||
inf.typeName = normalizedTypeName;
|
||||
inf.alias = aliasId;
|
||||
inf.constr = 0;
|
||||
inf.destr = 0;
|
||||
inf.creator = 0;
|
||||
inf.deleter = 0;
|
||||
ct->append(inf);
|
||||
return aliasId;
|
||||
}
|
||||
@ -561,8 +561,8 @@ void QMetaType::unregisterType(const char *typeName)
|
||||
if (ct->at(v).typeName == typeName) {
|
||||
QCustomTypeInfo &inf = (*ct)[v];
|
||||
inf.typeName.clear();
|
||||
inf.constr = 0;
|
||||
inf.destr = 0;
|
||||
inf.creator = 0;
|
||||
inf.deleter = 0;
|
||||
inf.alias = -1;
|
||||
}
|
||||
}
|
||||
@ -1028,7 +1028,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
|
||||
|
||||
\sa destroy(), isRegistered(), Type
|
||||
*/
|
||||
void *QMetaType::construct(int type, const void *copy)
|
||||
void *QMetaType::create(int type, const void *copy)
|
||||
{
|
||||
if (copy) {
|
||||
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 (!qMetaTypeGuiHelper)
|
||||
return 0;
|
||||
constr = qMetaTypeGuiHelper[type - FirstGuiType].constr;
|
||||
creator = qMetaTypeGuiHelper[type - FirstGuiType].creator;
|
||||
} else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
|
||||
if (!qMetaTypeWidgetsHelper)
|
||||
return 0;
|
||||
constr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].constr;
|
||||
creator = qMetaTypeWidgetsHelper[type - FirstWidgetsType].creator;
|
||||
} else {
|
||||
const QVector<QCustomTypeInfo> * const ct = customTypes();
|
||||
QReadLocker locker(customTypesLock());
|
||||
@ -1242,16 +1242,16 @@ void *QMetaType::construct(int type, const void *copy)
|
||||
return 0;
|
||||
if (ct->at(type - User).typeName.isEmpty())
|
||||
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.
|
||||
|
||||
\sa construct(), isRegistered(), Type
|
||||
\sa create(), isRegistered(), Type
|
||||
*/
|
||||
void QMetaType::destroy(int type, void *data)
|
||||
{
|
||||
@ -1390,28 +1390,28 @@ void QMetaType::destroy(int type, void *data)
|
||||
break;
|
||||
default: {
|
||||
const QVector<QCustomTypeInfo> * const ct = customTypes();
|
||||
Destructor destr = 0;
|
||||
Deleter deleter = 0;
|
||||
if (type >= FirstGuiType && type <= LastGuiType) {
|
||||
Q_ASSERT(qMetaTypeGuiHelper);
|
||||
|
||||
if (!qMetaTypeGuiHelper)
|
||||
return;
|
||||
destr = qMetaTypeGuiHelper[type - FirstGuiType].destr;
|
||||
deleter = qMetaTypeGuiHelper[type - FirstGuiType].deleter;
|
||||
} else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
|
||||
Q_ASSERT(qMetaTypeWidgetsHelper);
|
||||
|
||||
if (!qMetaTypeWidgetsHelper)
|
||||
return;
|
||||
destr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].destr;
|
||||
deleter = qMetaTypeWidgetsHelper[type - FirstWidgetsType].deleter;
|
||||
} else {
|
||||
QReadLocker locker(customTypesLock());
|
||||
if (type < User || !ct || ct->count() <= type - User)
|
||||
break;
|
||||
if (ct->at(type - User).typeName.isEmpty())
|
||||
break;
|
||||
destr = ct->at(type - User).destr;
|
||||
deleter = ct->at(type - User).deleter;
|
||||
}
|
||||
destr(data);
|
||||
deleter(data);
|
||||
break; }
|
||||
}
|
||||
}
|
||||
@ -1463,10 +1463,10 @@ void QMetaType::destroy(int type, void *data)
|
||||
\sa qRegisterMetaType(), QMetaType::isRegistered(), Q_DECLARE_METATYPE()
|
||||
*/
|
||||
|
||||
/*! \typedef QMetaType::Destructor
|
||||
/*! \typedef QMetaType::Deleter
|
||||
\internal
|
||||
*/
|
||||
/*! \typedef QMetaType::Constructor
|
||||
/*! \typedef QMetaType::Creator
|
||||
\internal
|
||||
*/
|
||||
/*! \typedef QMetaType::SaveOperator
|
||||
|
@ -103,8 +103,8 @@ public:
|
||||
User = 256
|
||||
};
|
||||
|
||||
typedef void (*Destructor)(void *);
|
||||
typedef void *(*Constructor)(const void *);
|
||||
typedef void (*Deleter)(void *);
|
||||
typedef void *(*Creator)(const void *);
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
typedef void (*SaveOperator)(QDataStream &, const void *);
|
||||
@ -114,13 +114,17 @@ public:
|
||||
static void registerStreamOperators(int type, SaveOperator saveOp,
|
||||
LoadOperator loadOp);
|
||||
#endif
|
||||
static int registerType(const char *typeName, Destructor destructor,
|
||||
Constructor constructor);
|
||||
static int registerType(const char *typeName, Deleter deleter,
|
||||
Creator creator);
|
||||
static int registerTypedef(const char *typeName, int aliasId);
|
||||
static int type(const char *typeName);
|
||||
static const char *typeName(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 unregisterType(const char *typeName);
|
||||
|
||||
@ -137,7 +141,7 @@ void qMetaTypeDeleteHelper(T *t)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void *qMetaTypeConstructHelper(const T *t)
|
||||
void *qMetaTypeCreateHelper(const T *t)
|
||||
{
|
||||
if (!t)
|
||||
return new T();
|
||||
@ -194,13 +198,13 @@ int qRegisterMetaType(const char *typeName
|
||||
if (typedefOf != -1)
|
||||
return QMetaType::registerTypedef(typeName, typedefOf);
|
||||
|
||||
typedef void*(*ConstructPtr)(const T*);
|
||||
ConstructPtr cptr = qMetaTypeConstructHelper<T>;
|
||||
typedef void*(*CreatePtr)(const T*);
|
||||
CreatePtr cptr = qMetaTypeCreateHelper<T>;
|
||||
typedef void(*DeletePtr)(T*);
|
||||
DeletePtr dptr = qMetaTypeDeleteHelper<T>;
|
||||
|
||||
return QMetaType::registerType(typeName, reinterpret_cast<QMetaType::Destructor>(dptr),
|
||||
reinterpret_cast<QMetaType::Constructor>(cptr));
|
||||
return QMetaType::registerType(typeName, reinterpret_cast<QMetaType::Deleter>(dptr),
|
||||
reinterpret_cast<QMetaType::Creator>(cptr));
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
|
@ -3242,7 +3242,7 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
|
||||
types[0] = 0; // return type
|
||||
args[0] = 0; // return value
|
||||
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,
|
||||
c->method_relative,
|
||||
c->callFunction,
|
||||
|
@ -180,7 +180,7 @@ static void construct(QVariant::Private *x, const void *copy)
|
||||
case QVariant::UserType:
|
||||
break;
|
||||
default:
|
||||
void *ptr = QMetaType::construct(x->type, copy);
|
||||
void *ptr = QMetaType::create(x->type, copy);
|
||||
if (!ptr) {
|
||||
x->type = QVariant::Invalid;
|
||||
} else {
|
||||
|
@ -637,8 +637,8 @@ const QVariant::Handler qt_gui_variant_handler = {
|
||||
|
||||
struct QMetaTypeGuiHelper
|
||||
{
|
||||
QMetaType::Constructor constr;
|
||||
QMetaType::Destructor destr;
|
||||
QMetaType::Creator creator;
|
||||
QMetaType::Deleter deleter;
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
QMetaType::SaveOperator saveOp;
|
||||
QMetaType::LoadOperator loadOp;
|
||||
@ -650,16 +650,16 @@ extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper;
|
||||
|
||||
#ifdef QT_NO_DATASTREAM
|
||||
# define Q_DECL_METATYPE_HELPER(TYPE) \
|
||||
typedef void *(*QConstruct##TYPE)(const TYPE *); \
|
||||
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
|
||||
typedef void (*QDestruct##TYPE)(TYPE *); \
|
||||
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
|
||||
typedef void *(*QCreate##TYPE)(const TYPE *); \
|
||||
static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
|
||||
typedef void (*QDelete##TYPE)(TYPE *); \
|
||||
static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>;
|
||||
#else
|
||||
# define Q_DECL_METATYPE_HELPER(TYPE) \
|
||||
typedef void *(*QConstruct##TYPE)(const TYPE *); \
|
||||
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
|
||||
typedef void (*QDestruct##TYPE)(TYPE *); \
|
||||
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
|
||||
typedef void *(*QCreate##TYPE)(const TYPE *); \
|
||||
static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
|
||||
typedef void (*QDelete##TYPE)(TYPE *); \
|
||||
static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \
|
||||
typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
|
||||
static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
|
||||
typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
|
||||
@ -704,12 +704,12 @@ Q_DECL_METATYPE_HELPER(QQuaternion)
|
||||
|
||||
#ifdef QT_NO_DATASTREAM
|
||||
# define Q_IMPL_METATYPE_HELPER(TYPE) \
|
||||
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
|
||||
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
|
||||
{ reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
|
||||
reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE) }
|
||||
#else
|
||||
# define Q_IMPL_METATYPE_HELPER(TYPE) \
|
||||
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
|
||||
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
|
||||
{ reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
|
||||
reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \
|
||||
reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
|
||||
reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void QTestData::append(int type, const void *data)
|
||||
d->dataCount, d->tag);
|
||||
QTEST_ASSERT(false);
|
||||
}
|
||||
d->data[d->dataCount] = QMetaType::construct(type, data);
|
||||
d->data[d->dataCount] = QMetaType::create(type, data);
|
||||
++d->dataCount;
|
||||
}
|
||||
|
||||
|
@ -135,8 +135,8 @@ static const QVariant::Handler widgets_handler = {
|
||||
|
||||
struct QMetaTypeGuiHelper
|
||||
{
|
||||
QMetaType::Constructor constr;
|
||||
QMetaType::Destructor destr;
|
||||
QMetaType::Creator creator;
|
||||
QMetaType::Deleter deleter;
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
QMetaType::SaveOperator saveOp;
|
||||
QMetaType::LoadOperator loadOp;
|
||||
@ -148,16 +148,16 @@ extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper;
|
||||
|
||||
#ifdef QT_NO_DATASTREAM
|
||||
# define Q_DECL_METATYPE_HELPER(TYPE) \
|
||||
typedef void *(*QConstruct##TYPE)(const TYPE *); \
|
||||
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
|
||||
typedef void (*QDestruct##TYPE)(TYPE *); \
|
||||
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
|
||||
typedef void *(*QCreate##TYPE)(const TYPE *); \
|
||||
static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
|
||||
typedef void (*QDelete##TYPE)(TYPE *); \
|
||||
static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>;
|
||||
#else
|
||||
# define Q_DECL_METATYPE_HELPER(TYPE) \
|
||||
typedef void *(*QConstruct##TYPE)(const TYPE *); \
|
||||
static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
|
||||
typedef void (*QDestruct##TYPE)(TYPE *); \
|
||||
static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
|
||||
typedef void *(*QCreate##TYPE)(const TYPE *); \
|
||||
static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \
|
||||
typedef void (*QDelete##TYPE)(TYPE *); \
|
||||
static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \
|
||||
typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
|
||||
static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
|
||||
typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
|
||||
@ -171,12 +171,12 @@ Q_DECL_METATYPE_HELPER(QSizePolicy)
|
||||
|
||||
#ifdef QT_NO_DATASTREAM
|
||||
# define Q_IMPL_METATYPE_HELPER(TYPE) \
|
||||
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
|
||||
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
|
||||
{ reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
|
||||
reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE) }
|
||||
#else
|
||||
# define Q_IMPL_METATYPE_HELPER(TYPE) \
|
||||
{ reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
|
||||
reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
|
||||
{ reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \
|
||||
reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \
|
||||
reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
|
||||
reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ private slots:
|
||||
void normalizedTypes();
|
||||
void typeName_data();
|
||||
void typeName();
|
||||
void construct();
|
||||
void create();
|
||||
void typedefs();
|
||||
void isRegistered_data();
|
||||
void isRegistered();
|
||||
@ -133,15 +133,15 @@ protected:
|
||||
++failureCount;
|
||||
qWarning() << "Wrong typeName returned for" << tp;
|
||||
}
|
||||
void *buf = QMetaType::construct(tp, 0);
|
||||
void *buf2 = QMetaType::construct(tp, buf);
|
||||
void *buf = QMetaType::create(tp, 0);
|
||||
void *buf2 = QMetaType::create(tp, buf);
|
||||
if (!buf) {
|
||||
++failureCount;
|
||||
qWarning() << "Null buffer returned by QMetaType::construct(tp, 0)";
|
||||
qWarning() << "Null buffer returned by QMetaType::create(tp, 0)";
|
||||
}
|
||||
if (!buf2) {
|
||||
++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, buf2);
|
||||
@ -268,10 +268,10 @@ void tst_QMetaType::typeName()
|
||||
QCOMPARE(QString::fromLatin1(QMetaType::typeName(aType)), aTypeName);
|
||||
}
|
||||
|
||||
void tst_QMetaType::construct()
|
||||
void tst_QMetaType::create()
|
||||
{
|
||||
QSize x(1, 1);
|
||||
void *size = QMetaType::construct(QMetaType::QSize, &x);
|
||||
void *size = QMetaType::create(QMetaType::QSize, &x);
|
||||
QVERIFY(size);
|
||||
QCOMPARE(static_cast<QSize *>(size)->width(), 1);
|
||||
QMetaType::destroy(QMetaType::QSize, size);
|
||||
|
@ -1298,7 +1298,7 @@ void tst_QVariant::matrix()
|
||||
qVariantSetValue(variant, QMatrix().rotate(90));
|
||||
QCOMPARE(QMatrix().rotate(90), qVariantValue<QMatrix>(variant));
|
||||
|
||||
void *mmatrix = QMetaType::construct(QVariant::Matrix, 0);
|
||||
void *mmatrix = QMetaType::create(QVariant::Matrix, 0);
|
||||
QVERIFY(mmatrix);
|
||||
QMetaType::destroy(QVariant::Matrix, mmatrix);
|
||||
}
|
||||
@ -1313,7 +1313,7 @@ void tst_QVariant::matrix4x4()
|
||||
qVariantSetValue(variant, m);
|
||||
QCOMPARE(m, qVariantValue<QMatrix4x4>(variant));
|
||||
|
||||
void *mmatrix = QMetaType::construct(QVariant::Matrix4x4, 0);
|
||||
void *mmatrix = QMetaType::create(QVariant::Matrix4x4, 0);
|
||||
QVERIFY(mmatrix);
|
||||
QMetaType::destroy(QVariant::Matrix4x4, mmatrix);
|
||||
}
|
||||
@ -1326,7 +1326,7 @@ void tst_QVariant::transform()
|
||||
qVariantSetValue(variant, QTransform().rotate(90));
|
||||
QCOMPARE(QTransform().rotate(90), qVariantValue<QTransform>(variant));
|
||||
|
||||
void *mmatrix = QMetaType::construct(QVariant::Transform, 0);
|
||||
void *mmatrix = QMetaType::create(QVariant::Transform, 0);
|
||||
QVERIFY(mmatrix);
|
||||
QMetaType::destroy(QVariant::Transform, mmatrix);
|
||||
}
|
||||
@ -1340,7 +1340,7 @@ void tst_QVariant::vector2D()
|
||||
qVariantSetValue(variant, QVector2D(0.1, 0.2));
|
||||
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);
|
||||
QMetaType::destroy(QVariant::Vector2D, pvector);
|
||||
}
|
||||
@ -1353,7 +1353,7 @@ void tst_QVariant::vector3D()
|
||||
qVariantSetValue(variant, QVector3D(0.1, 0.2, 0.3));
|
||||
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);
|
||||
QMetaType::destroy(QVariant::Vector3D, pvector);
|
||||
}
|
||||
@ -1366,7 +1366,7 @@ void tst_QVariant::vector4D()
|
||||
qVariantSetValue(variant, QVector4D(0.1, 0.2, 0.3, 0.4));
|
||||
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);
|
||||
QMetaType::destroy(QVariant::Vector4D, pvector);
|
||||
}
|
||||
@ -1379,7 +1379,7 @@ void tst_QVariant::quaternion()
|
||||
qVariantSetValue(variant, QQuaternion(0.1, 0.2, 0.3, 0.4));
|
||||
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);
|
||||
QMetaType::destroy(QVariant::Quaternion, pquaternion);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void tst_QMetaType::constructCoreType()
|
||||
QFETCH(int, typeId);
|
||||
QBENCHMARK {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ void tst_QMetaType::constructCoreTypeCopy()
|
||||
const void *copy = other.constData();
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
void *data = QMetaType::construct(typeId, copy);
|
||||
void *data = QMetaType::create(typeId, copy);
|
||||
QMetaType::destroy(typeId, data);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void tst_QGuiMetaType::constructGuiType()
|
||||
QFETCH(int, typeId);
|
||||
QBENCHMARK {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ void tst_QGuiMetaType::constructGuiTypeCopy()
|
||||
const void *copy = other.constData();
|
||||
QBENCHMARK {
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
void *data = QMetaType::construct(typeId, copy);
|
||||
void *data = QMetaType::create(typeId, copy);
|
||||
QMetaType::destroy(typeId, data);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user