diff --git a/doc/changelog.dox b/doc/changelog.dox index cafb789411..046e828f8f 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -217,6 +217,9 @@ See also: to be ignored even though Vsync was in fact not enabled. - Fixed an otherwise harmless OOB access in @ref MeshTools::tipsify() that could trigger ASan or debug iterator errors +- With @ref Corrade/Utility/DebugStl.h not being included, @ref std::string + instances could get accidentally printed as @ref ResourceKey instances. + Added and explicit header dependency to avoid such cases. @subsection changelog-latest-deprecated Deprecated APIs diff --git a/src/Magnum/Resource.h b/src/Magnum/Resource.h index bc9bf6983f..ac4dbedd11 100644 --- a/src/Magnum/Resource.h +++ b/src/Magnum/Resource.h @@ -33,6 +33,13 @@ #include #include +/* This is needed because ResourceKey is implicitly convertible from a + std::string -- and if DebugStl.h wouldn't be included, an attempt to print a + std::string would choose the ResourceKey printer instead, producing unwanted + results. */ +/** @todo remove when we have a StringView and ResourceKey is ported to it */ +#include + #include "Magnum/Magnum.h" #include "Magnum/visibility.h" @@ -91,7 +98,7 @@ class ResourceKey: public Utility::MurmurHash2::Digest { explicit ResourceKey(std::size_t key): Utility::MurmurHash2::Digest{Utility::MurmurHash2::Digest::fromByteArray(reinterpret_cast(&key))} {} /** @brief Constructor */ - ResourceKey(const std::string& key): Utility::MurmurHash2::Digest(Utility::MurmurHash2()(key)) {} + /*implicit*/ ResourceKey(const std::string& key): Utility::MurmurHash2::Digest(Utility::MurmurHash2()(key)) {} /** * @brief Constructor diff --git a/src/Magnum/Test/ResourceManagerTest.cpp b/src/Magnum/Test/ResourceManagerTest.cpp index d82353dfb5..89a68179a1 100644 --- a/src/Magnum/Test/ResourceManagerTest.cpp +++ b/src/Magnum/Test/ResourceManagerTest.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include "Magnum/AbstractResourceLoader.h"