canvas/paint: ++exception handling

enhanced reference count verification
to prevent unintentional deletion of used composition targets.
This commit is contained in:
Hermet Park 2023-10-24 14:54:45 +09:00
parent 8200bc5fc3
commit 6e3674b904
2 changed files with 7 additions and 3 deletions

View file

@ -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) {
delete(compData->target);
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;

View file

@ -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;
}