diff options
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.h | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 5 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 10 |
4 files changed, 19 insertions, 8 deletions
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 0a5181a508..cf76511f25 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -137,7 +137,11 @@ public: static void installTranslator(QTranslator * messageFile); static void removeTranslator(QTranslator * messageFile); #endif - enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = Latin1 }; + enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = Latin1 +#if QT_DEPRECATED_SINCE(5, 0) + , CodecForTr = Latin1 +#endif + }; static QString translate(const char * context, const char * key, const char * disambiguation = 0, diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index a5dc179113..8474635fe7 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -375,8 +375,9 @@ void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp, \sa type(), isRegistered(), Type */ -const char *QMetaType::typeName(int type) +const char *QMetaType::typeName(int typeId) { + const uint type = typeId; // In theory it can be filled during compilation time, but for some reason template code // that is able to do it causes GCC 4.6 to generate additional 3K of executable code. Probably // it is not worth of it. @@ -398,7 +399,7 @@ const char *QMetaType::typeName(int type) } else { const QVector<QCustomTypeInfo> * const ct = customTypes(); QReadLocker locker(customTypesLock()); - return ct && ct->count() > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty() + return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty() ? ct->at(type - QMetaType::User).typeName.constData() : 0; } diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index fb2bce7d7b..4eadb34ea1 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -45,6 +45,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qatomic.h> #include <QtCore/qbytearray.h> +#include <QtCore/qisenum.h> #include <new> @@ -210,7 +211,8 @@ public: NeedsConstruction = 0x1, NeedsDestruction = 0x2, MovableType = 0x4, - PointerToQObject = 0x8 + PointerToQObject = 0x8, + IsEnumeration = 0x10 }; Q_DECLARE_FLAGS(TypeFlags, TypeFlag) @@ -466,6 +468,8 @@ int qRegisterMetaType(const char *typeName } if (QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value) flags |= QMetaType::PointerToQObject; + if (Q_IS_ENUM(T)) + flags |= QMetaType::IsEnumeration; return QMetaType::registerType(typeName, qMetaTypeDeleteHelper<T>, qMetaTypeCreateHelper<T>, diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 39e8b4360f..8058a06117 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1676,12 +1676,12 @@ void QVariant::load(QDataStream &s) // by moving all ids down by 97. typeId -= 97; } else if (typeId == 69 /* QIcon */) { - // In Qt5 after modularization project this types where moved to a separate module (and ids were downgraded) + // In Qt5 after modularization project these types where moved to a separate module (and ids were downgraded) typeId = QMetaType::QIcon; } else if (typeId == 75 /* QSizePolicy */) { typeId = QMetaType::QSizePolicy; } else if (typeId >= 70) { - // and as a result this types recieved lower ids too + // and as a result these types received lower ids too if (typeId <= 74) { // QImage QPolygon QRegion QBitmap QCursor typeId -=1; } else if (typeId <= 86) { // QKeySequence QPen QTextLength QTextFormat QMatrix QTransform QMatrix4x4 QVector2D QVector3D QVector4D QQuaternion @@ -1749,12 +1749,12 @@ void QVariant::save(QDataStream &s) const // by moving all ids down by 97. typeId += 97; } else if (typeId == QMetaType::QIcon) { - // In Qt5 after modularization project this types where moved to a separate module (and ids were downgraded) + // In Qt5 after modularization project these types where moved to a separate module (and ids were downgraded) typeId = 69; } else if (typeId == QMetaType::QSizePolicy) { typeId = 75; } else if (typeId >= QMetaType::QImage) { - // and as a result this types recieved lower ids too + // and as a result these types received lower ids too if (typeId <= QMetaType::QCursor) { typeId +=1; } else if (typeId <= QMetaType::QQuaternion) { @@ -2445,6 +2445,8 @@ bool QVariant::canConvert(int targetTypeId) const if (currentType == uint(targetTypeId)) return true; + if (targetTypeId < 0 || targetTypeId >= QMetaType::User) + return false; // FIXME It should be LastCoreType intead of Uuid if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { |