mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 15:50:49 +01:00
Fix AllocationFailure when multiple instances
This commit is contained in:
@@ -8,23 +8,31 @@
|
||||
void TreeNode::release() {
|
||||
m_referenceCounter--;
|
||||
if (m_referenceCounter == 0) {
|
||||
if (numberOfChildren() != 0) {
|
||||
int lastIdentifier = lastChild()->identifier();
|
||||
TreeNode * child = next();
|
||||
bool lastChildReleased = false;
|
||||
while (!lastChildReleased) {
|
||||
lastChildReleased = child->identifier() == lastIdentifier;
|
||||
int nextSiblingIdentifier = lastChildReleased ? -1 : child->nextSibling()->identifier();
|
||||
child->release();
|
||||
if (nextSiblingIdentifier != -1) {
|
||||
child = TreePool::sharedPool()->node(nextSiblingIdentifier);
|
||||
}
|
||||
releaseChildrenAndDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void TreeNode::releaseChildren() {
|
||||
if (numberOfChildren() != 0) {
|
||||
int lastIdentifier = lastChild()->identifier();
|
||||
TreeNode * child = next();
|
||||
bool lastChildReleased = false;
|
||||
while (!lastChildReleased) {
|
||||
lastChildReleased = child->identifier() == lastIdentifier;
|
||||
int nextSiblingIdentifier = lastChildReleased ? -1 : child->nextSibling()->identifier();
|
||||
child->release();
|
||||
if (nextSiblingIdentifier != -1) {
|
||||
child = TreePool::sharedPool()->node(nextSiblingIdentifier);
|
||||
}
|
||||
}
|
||||
TreePool::sharedPool()->discardTreeNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
void TreeNode::releaseChildrenAndDestroy() {
|
||||
releaseChildren();
|
||||
TreePool::sharedPool()->discardTreeNode(this);
|
||||
}
|
||||
|
||||
// Hierarchy
|
||||
|
||||
TreeNode * TreeNode::parentTree() const {
|
||||
|
||||
Reference in New Issue
Block a user