common paint: fix memory leak case.

free the previous composition target if any,
before reset with the new one.
This commit is contained in:
Hermet Park 2021-03-23 16:35:22 +09:00
parent 1a7d41ce71
commit aa68481fb7

View file

@ -224,6 +224,7 @@ namespace tvg
bool composite(Paint* target, CompositeMethod method) bool composite(Paint* target, CompositeMethod method)
{ {
if ((!target && method != CompositeMethod::None) || (target && method == CompositeMethod::None)) return false; if ((!target && method != CompositeMethod::None) || (target && method == CompositeMethod::None)) return false;
if (cmpTarget) delete(cmpTarget);
cmpTarget = target; cmpTarget = target;
cmpMethod = method; cmpMethod = method;
return true; return true;