do not copy the variant before checking if it can be converted in QVariant::canConvert()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-06-07 16:11:48 +03:00
parent 74fef30990
commit 4acfa93e66

View file

@ -2669,19 +2669,22 @@ bool QVariant::convert(Type t)
if (d.type == int(t))
return true;
QVariant oldValue = *this;
if (!canConvert(t)) {
clear();
if (!oldValue.canConvert(t))
return false;
}
QVariant oldValue = *this;
clear();
create(t, nullptr);
if (oldValue.isNull())
if (oldValue.isNull()) {
return false;
}
bool isOk = true;
if (!handler->convert(&oldValue.d, t, data(), &isOk))
if (!handler->convert(&oldValue.d, t, data(), &isOk)) {
isOk = false;
}
d.is_null = !isOk;
return isOk;
}