QVariant::fromStdVariant(): protect against accidental fromValue() ADL pick-ups
The use of unqualified fromValue(arg) in the visitor implementation
invites non-QVariant fromValue(T) overloads to be found using ADL,
which just happen to compile because their return value implicitly
converts to QVariant (like most stuff does).
To rule this out, use FQN QVariant::fromValue() to switch off ADL.
[ChangeLog][QtCore][QVariant] The fromStdVariant() function used an
unqualifed fromValue() call to convert each alternative type in the
std::variant. It now uses qualified QVariant::fromValue() to avoid
picking up unrelated fromValue() overloads whose return value just
happens to implicitly convert to QVariant.
Amends 5927acaf65
.
Pick-to: 6.5 6.2
Change-Id: Ica21b08c919459d0a740af03f451e4ffe224b641
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
60f739f51f
commit
6f529c38ce
@ -498,7 +498,7 @@ public:
|
||||
{
|
||||
if (value.valueless_by_exception())
|
||||
return QVariant();
|
||||
return std::visit([](const auto &arg) { return fromValue(arg); }, value);
|
||||
return std::visit([](const auto &arg) { return QVariant::fromValue(arg); }, value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user