Browse Source

Trade: make the MaterialData duplicate asserts more paranoid.

Libc++ is that you who's this shitty?
pull/525/head
Vladimír Vondruš 5 years ago
parent
commit
372e60dd0f
  1. 9
      src/Magnum/Trade/MaterialData.cpp

9
src/Magnum/Trade/MaterialData.cpp

@ -233,8 +233,13 @@ MaterialData::MaterialData(const MaterialTypes types, Containers::Array<Material
std::sort(_data + begin, _data + end, [](const MaterialAttributeData& a, const MaterialAttributeData& b) { std::sort(_data + begin, _data + end, [](const MaterialAttributeData& a, const MaterialAttributeData& b) {
/* Need to check here (instead of in the outer for loop) as we /* Need to check here (instead of in the outer for loop) as we
exit the loop right after the sort and thus duplicates that exit the loop right after the sort and thus duplicates that
occur after the first non-sorted pair wouldn't get detected. */ occur after the first non-sorted pair wouldn't get detected.
CORRADE_ASSERT(a.name() != b.name(),
Additionally an *extra paranoid* check for shitty STL
implementations that might call this comparator with both
arguments the same (in which case the assert would fire,
which is undesirable). */
CORRADE_ASSERT(&a == &b || a.name() != b.name(),
"Trade::MaterialData: duplicate attribute" << a.name(), false); "Trade::MaterialData: duplicate attribute" << a.name(), false);
return a.name() < b.name(); return a.name() < b.name();
}); });

Loading…
Cancel
Save