Fix crash in QVariant::canConvert.
The function was crashing when an unsupported type id was given as an input argument. Change-Id: I2b0e3e6d43f6f248dc71532f8e6485efe68e8120 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>bb10
parent
779b3188a9
commit
f71487da3a
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -612,6 +612,12 @@ void tst_QVariant::canConvert()
|
|||
QCOMPARE(val.canConvert(QVariant::Time), TimeCast);
|
||||
QCOMPARE(val.canConvert(QVariant::UInt), UIntCast);
|
||||
QCOMPARE(val.canConvert(QVariant::ULongLong), ULongLongCast);
|
||||
|
||||
// Invalid type ids
|
||||
QCOMPARE(val.canConvert(-1), false);
|
||||
QCOMPARE(val.canConvert(-23), false);
|
||||
QCOMPARE(val.canConvert(-23876), false);
|
||||
QCOMPARE(val.canConvert(23876), false);
|
||||
}
|
||||
|
||||
void tst_QVariant::toInt_data()
|
||||
|
|
|
|||
Loading…
Reference in New Issue