Prevent name collisions in KTX from causing crashes

This commit is contained in:
Brad Davis 2017-02-23 13:04:04 -08:00
parent e7a23e219d
commit cd8f3e1b01
2 changed files with 4 additions and 2 deletions

View file

@ -117,6 +117,9 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
}
auto ktxBuffer = ktx::KTX::create(header, images);
auto expectedMipCount = texture.evalNumMips();
assert(expectedMipCount == ktxBuffer->_images.size());
assert(expectedMipCount == header.numberOfMipmapLevels);
assert(0 == memcmp(&header, ktxBuffer->getHeader(), sizeof(ktx::Header)));
assert(ktxBuffer->_images.size() == images.size());

View file

@ -103,8 +103,7 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo
}
});
std::string cleanedName = name;
cleanedName = cleanedName.substr(cleanedName.find_last_of((char) '//') + 1);
std::string cleanedName = QUrl::toPercentEncoding(name.c_str()).toStdString();
std::string cacheFilename(ktxCacheFolder.toStdString());
cacheFilename += "/";
cacheFilename += cleanedName;