mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
canvas/paint: ++exception handling
enhanced reference count verification to prevent unintentional deletion of used composition targets.
This commit is contained in:
parent
8200bc5fc3
commit
6e3674b904
2 changed files with 7 additions and 3 deletions
|
@ -73,7 +73,7 @@ namespace tvg
|
|||
~Impl()
|
||||
{
|
||||
if (compData) {
|
||||
delete(compData->target);
|
||||
if (P(compData->target)->unref() == 0) delete(compData->target);
|
||||
free(compData);
|
||||
}
|
||||
delete(smethod);
|
||||
|
@ -141,7 +141,10 @@ namespace tvg
|
|||
if ((!target && method != CompositeMethod::None) || (target && method == CompositeMethod::None)) return false;
|
||||
|
||||
if (compData) {
|
||||
P(compData->target)->unref();
|
||||
if ((compData->target != target) && P(compData->target)->refCnt == 0) {
|
||||
delete(compData->target);
|
||||
}
|
||||
//Reset scenario
|
||||
if (!target && method == CompositeMethod::None) {
|
||||
free(compData);
|
||||
|
@ -152,6 +155,7 @@ namespace tvg
|
|||
if (!target && method == CompositeMethod::None) return true;
|
||||
compData = static_cast<Composite*>(calloc(1, sizeof(Composite)));
|
||||
}
|
||||
P(target)->ref();
|
||||
compData->target = target;
|
||||
compData->source = source;
|
||||
compData->method = method;
|
||||
|
|
|
@ -62,7 +62,7 @@ Result Shape::reset() noexcept
|
|||
pImpl->rs.path.cmds.clear();
|
||||
pImpl->rs.path.pts.clear();
|
||||
|
||||
pImpl->flag = RenderUpdateFlag::Path;
|
||||
pImpl->flag |= RenderUpdateFlag::Path;
|
||||
|
||||
return Result::Success;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue