From 4959f7d9488db413d6956575e7faab3439a65561 Mon Sep 17 00:00:00 2001 From: silverqx Date: Sat, 26 Nov 2022 16:27:57 +0100 Subject: [PATCH] bugfix previous commit --- include/orm/tiny/concerns/hasattributes.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/orm/tiny/concerns/hasattributes.hpp b/include/orm/tiny/concerns/hasattributes.hpp index d02504c8e..330ebb32f 100644 --- a/include/orm/tiny/concerns/hasattributes.hpp +++ b/include/orm/tiny/concerns/hasattributes.hpp @@ -1436,17 +1436,21 @@ namespace Orm::Tiny::Concerns // Throw if the given attribute can not be converted to the given cast type throwIfCanNotCastAttribute(key, castType, metaType, value_, functionName); - /* Still check for the false value and log to the debug stream, but not if - the value_ is null, because converting null QVariant will always return - false and the QVariant type will be changed anyway. */ -#ifdef TINYORM_DEBUG #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!value_.convert(metaType) && !value_.isNull()) + const auto &metaTypeId = metaType; #else - if (!value_.convert(metaType.id()) && !value_.isNull()) + const auto metaTypeId = metaType.id(); #endif + +#ifdef TINYORM_DEBUG + /* Still check for the false value and log to the debug stream, but not if + the value_ is null, because converting null QVariant will always return + false and the QVariant type will be changed anyway. */ + if (!value_.convert(metaTypeId) && !value_.isNull()) // Log if the QVariant::convert() for the given attribute failed logIfConvertAttributeFailed(key, castType, metaType, functionName); +#else + value_.convert(metaTypeId); #endif return value_;