From: Ivailo Monev Date: Sun, 26 Jan 2020 13:16:08 +0000 (+0000) Subject: move custom types access closer to the scope it is used in in QMetaType X-Git-Tag: 4.12.0~4098 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=74dc93c4b60c7f15067adaf8a4134836649fed0c;p=kde%2FKatie.git move custom types access closer to the scope it is used in in QMetaType Signed-off-by: Ivailo Monev --- diff --git a/src/core/kernel/qmetatype.cpp b/src/core/kernel/qmetatype.cpp index b225e254d..5d2fbf2af 100644 --- a/src/core/kernel/qmetatype.cpp +++ b/src/core/kernel/qmetatype.cpp @@ -467,8 +467,7 @@ static int qMetaTypeCustomType_unlocked(const char *typeName, int length) int QMetaType::registerType(const char *typeName, Destructor destructor, Constructor constructor) { - QVector *ct = customTypes(); - if (!ct || !typeName || !destructor || !constructor) + if (!typeName || !destructor || !constructor) return -1; #ifdef QT_NO_QOBJECT @@ -482,6 +481,7 @@ int QMetaType::registerType(const char *typeName, Destructor destructor, if (!idx) { QWriteLocker locker(customTypesLock()); + QVector *ct = customTypes(); idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(), normalizedTypeName.size()); if (!idx) { @@ -504,8 +504,7 @@ int QMetaType::registerType(const char *typeName, Destructor destructor, */ int QMetaType::registerTypedef(const char* typeName, int aliasId) { - QVector *ct = customTypes(); - if (!ct || !typeName) + if (!typeName) return -1; #ifdef QT_NO_QOBJECT @@ -523,6 +522,7 @@ int QMetaType::registerTypedef(const char* typeName, int aliasId) } QWriteLocker locker(customTypesLock()); + QVector *ct = customTypes(); idx = qMetaTypeCustomType_unlocked(normalizedTypeName.constData(), normalizedTypeName.size()); @@ -547,8 +547,7 @@ int QMetaType::registerTypedef(const char* typeName, int aliasId) */ void QMetaType::unregisterType(const char *typeName) { - QVector *ct = customTypes(); - if (!ct || !typeName) + if (!typeName) return; #ifdef QT_NO_QOBJECT @@ -557,6 +556,7 @@ void QMetaType::unregisterType(const char *typeName) NS(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName); #endif QWriteLocker locker(customTypesLock()); + QVector *ct = customTypes(); for (int v = 0; v < ct->count(); ++v) { if (ct->at(v).typeName == typeName) { QCustomTypeInfo &inf = (*ct)[v];