mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
common: fix a memory leak after scene->clear(true)
If renderer was null, paints was cleared (count set to zero), but data was not deleted regardless free boolean.
This commit is contained in:
parent
0df8c00519
commit
24cebf5cc5
1 changed files with 9 additions and 7 deletions
|
@ -173,17 +173,19 @@ struct Scene::Impl
|
|||
void clear(bool free)
|
||||
{
|
||||
//Clear render target before drawing
|
||||
if (!renderer || !renderer->clear()) {
|
||||
paints.clear();
|
||||
return;
|
||||
if (renderer && renderer->clear()) {
|
||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||
(*paint)->pImpl->dispose(*renderer);
|
||||
}
|
||||
renderer = nullptr;
|
||||
}
|
||||
//free paints
|
||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||
(*paint)->pImpl->dispose(*renderer);
|
||||
if (free) delete(*paint);
|
||||
if (free) {
|
||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||
delete(*paint);
|
||||
}
|
||||
}
|
||||
paints.clear();
|
||||
renderer = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue