common: fix a potential memory leak after clear()
authorHermet Park <chuneon.park@samsung.com>
Fri, 14 May 2021 11:19:03 +0000 (20:19 +0900)
committerHermet Park <chuneon.park@samsung.com>
Fri, 28 May 2021 08:13:38 +0000 (17:13 +0900)
commiteab6868a873878c8cb154c41a7e711eb4743a763
tree989a27d6bf48a56b9262dcdb4a3d42358dc5999c
parent4804dcd5ee22b95b69f8eaadc31015c8c5cc571c
common: fix a potential memory leak after clear()

Paints must clear canvas engine data if they were dismissed from the canvas,

1. Canvas::clear(free = false) must retain all the paints from the paints hierarchy
so that user keeps the all dangled paints lifecycle.
In this scenario, it could leak the engine data of paints, this patch fixes it.

2. Previously, t just keeps the immediate paints lives of canvas, but not them of children of scene nor picture.
This patch changes a policy which was not considered seriously,
Now it keeps the all paints lives through the tree-hieararchy.

3. Also changed the Scene::clear() behavior identical to Canvas::clear() for consistency.

@API Modification:

Change-Id: I58708f7c759f48be30853364da87b70d63adbe22
From: Result Scene::clear() noexcept;
To: Result Scene::clear(bool free = true) noexcept;
inc/thorvg.h
inc/thorvg_capi.h
src/bindings/capi/tvgCapi.cpp
src/lib/tvgCanvasImpl.h
src/lib/tvgPictureImpl.h
src/lib/tvgScene.cpp
src/lib/tvgSceneImpl.h