diff options
author | Frank Meerkoetter <frank.meerkoetter@basyskom.com> | 2016-01-05 19:57:33 +0100 |
---|---|---|
committer | Frank Meerkoetter <frank.meerkoetter@basyskom.com> | 2016-01-05 20:51:04 +0000 |
commit | 1f8dc15888765a1df586312201a8dbf6d1abfc76 (patch) | |
tree | 4ba6e5b410b3cd470c42003d76de1a81a6f1ef93 /src | |
parent | 3fb05bd937b0d8af2ff51fd4e495d4759d9f6bdb (diff) |
Fix leak, less copying
Do not leak the textureContent array.
Change-Id: I9e7ed258206f0485a02482958ba9fcf6396b3170
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/sceneparsers/assimp/assimpparser.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/sceneparsers/assimp/assimpparser.cpp b/src/plugins/sceneparsers/assimp/assimpparser.cpp index 5ffc1a4c8..040fc3a8a 100644 --- a/src/plugins/sceneparsers/assimp/assimpparser.cpp +++ b/src/plugins/sceneparsers/assimp/assimpparser.cpp @@ -678,7 +678,8 @@ void AssimpParser::loadEmbeddedTexture(uint textureIndex) uint textureSize = assimpTexture->mWidth * (isCompressed ? assimpTexture->mHeight : 1); // Set texture to RGBA8888 - char *textureContent = new char[textureSize * 4]; + QByteArray textureContent; + textureContent.reserve(textureSize * 4); for (uint i = 0; i < textureSize; i++) { uint idx = i * 4; aiTexel texel = assimpTexture->pcData[i]; @@ -687,7 +688,7 @@ void AssimpParser::loadEmbeddedTexture(uint textureIndex) textureContent[idx + 2] = texel.b; textureContent[idx + 3] = texel.a; } - imageData->setData(QByteArray(textureContent, textureSize * 4)); + imageData->setData(textureContent); texture->addTextureImage(imageData); m_scene->m_embeddedTextures[textureIndex] = texture; } |