diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-04-20 12:49:05 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-04-20 13:56:39 +0000 |
commit | 2136406b4cac2e6db4786170cfa9be5372e27da7 (patch) | |
tree | d399c246171cfc24e574d1fe02661b6361c5afa3 /src/corelib/kernel/qpropertyprivate.h | |
parent | 6560778616b090f8cc73700675ec2ef385953fb6 (diff) |
Work around MSVC compilation issue
MSVC does not seem to instantiate code in the else branch of the
constexpr if statement even though the condition is true. This causes
an error if the PropertyType is void, as we then would attempt to
create an object of type void.
Work-around the issue by explicitly checking that the type is not void.
Fixes: QTBUG-92962
Change-Id: Ie5acb6fae532bcc441be34418d4724de9d65b340
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/kernel/qpropertyprivate.h')
-rw-r--r-- | src/corelib/kernel/qpropertyprivate.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index f59221c4df..5b6a9557f9 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -199,7 +199,7 @@ struct BindingFunctionVTable static_assert (std::is_invocable_r_v<bool, Callable, QMetaType, QUntypedPropertyData *> ); auto untypedEvaluationFunction = static_cast<Callable *>(f); return std::invoke(*untypedEvaluationFunction, metaType, dataPtr); - } else { + } else if constexpr (!std::is_same_v<PropertyType, void>) { // check for void to woraround MSVC issue Q_UNUSED(metaType); QPropertyData<PropertyType> *propertyPtr = static_cast<QPropertyData<PropertyType> *>(dataPtr); // That is allowed by POSIX even if Callable is a function pointer @@ -211,6 +211,10 @@ struct BindingFunctionVTable } propertyPtr->setValueBypassingBindings(std::move(newValue)); return true; + } else { + // Our code will never instantiate this + Q_UNREACHABLE(); + return false; } }, /*destroy*/[](void *f){ static_cast<Callable *>(f)->~Callable(); }, |