mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-15 12:34:30 +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)
|
void clear(bool free)
|
||||||
{
|
{
|
||||||
//Clear render target before drawing
|
//Clear render target before drawing
|
||||||
if (!renderer || !renderer->clear()) {
|
if (renderer && renderer->clear()) {
|
||||||
paints.clear();
|
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||||
return;
|
(*paint)->pImpl->dispose(*renderer);
|
||||||
|
}
|
||||||
|
renderer = nullptr;
|
||||||
}
|
}
|
||||||
//free paints
|
//free paints
|
||||||
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
if (free) {
|
||||||
(*paint)->pImpl->dispose(*renderer);
|
for (auto paint = paints.data; paint < (paints.data + paints.count); ++paint) {
|
||||||
if (free) delete(*paint);
|
delete(*paint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
paints.clear();
|
paints.clear();
|
||||||
renderer = nullptr;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue