From 7498d5742fe3ac808b1508fe7addd00408b63484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 31 Dec 2020 01:41:32 +0100 Subject: [PATCH] Trade: fix unused variable warning when building with CORRADE_NO_ASSERT. --- src/Magnum/Trade/MaterialData.cpp | 4 ++++ src/Magnum/Trade/MaterialData.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/Magnum/Trade/MaterialData.cpp b/src/Magnum/Trade/MaterialData.cpp index a888e2d27..52ae352b4 100644 --- a/src/Magnum/Trade/MaterialData.cpp +++ b/src/Magnum/Trade/MaterialData.cpp @@ -366,7 +366,9 @@ UnsignedInt MaterialData::layerFactorTexture(const UnsignedInt layer) const { } UnsignedInt MaterialData::layerFactorTexture(const Containers::StringView layer) const { + #ifndef CORRADE_NO_ASSERT const UnsignedInt layerId = layerFor(layer); + #endif CORRADE_ASSERT(layerId != ~UnsignedInt{}, "Trade::MaterialData::layerFactorTexture(): layer" << layer << "not found", {}); /* Not delegating into layerFactorTexture() in order to have layer name @@ -389,7 +391,9 @@ MaterialTextureSwizzle MaterialData::layerFactorTextureSwizzle(const UnsignedInt } MaterialTextureSwizzle MaterialData::layerFactorTextureSwizzle(const Containers::StringView layer) const { + #ifndef CORRADE_NO_ASSERT const UnsignedInt layerId = layerFor(layer); + #endif CORRADE_ASSERT(layerId != ~UnsignedInt{}, "Trade::MaterialData::layerFactorTextureSwizzle(): layer" << layer << "not found", {}); CORRADE_ASSERT(hasAttribute(layerId, MaterialAttribute::LayerFactorTexture), diff --git a/src/Magnum/Trade/MaterialData.h b/src/Magnum/Trade/MaterialData.h index 31801eb53..87acd64cc 100644 --- a/src/Magnum/Trade/MaterialData.h +++ b/src/Magnum/Trade/MaterialData.h @@ -2721,7 +2721,9 @@ template T MaterialData::attribute(const UnsignedInt layer, const Unsig #ifdef CORRADE_GRACEFUL_ASSERT if(!value) return {}; #endif + #ifndef CORRADE_NO_ASSERT const Trade::MaterialAttributeData& data = _data[layerOffset(layer) + id]; + #endif CORRADE_ASSERT(Implementation::MaterialAttributeTypeFor::type() == data._data.type, "Trade::MaterialData::attribute(): improper type requested for" << (data._data.data + 1) << "of" << data._data.type, {}); return *reinterpret_cast(value);