mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 07:40:42 +01:00
[poincare] Allow construction of a TreeRef from nullptr node
This commit is contained in:
@@ -83,8 +83,14 @@ public:
|
||||
TreeByReference treeRefChild = TreeByReference::childAtIndex(i);
|
||||
return LayoutReference(static_cast<LayoutNode *>(treeRefChild.node()));
|
||||
}
|
||||
LayoutReference root() const;
|
||||
LayoutReference parent() const { return isUninitialized() ? LayoutReference() : LayoutReference(node()->parent()); }
|
||||
LayoutReference root() const {
|
||||
assert(!isUninitialized());
|
||||
return LayoutReference(node()->root());
|
||||
}
|
||||
LayoutReference parent() const {
|
||||
assert(!isUninitialized());
|
||||
return LayoutReference(node()->parent());
|
||||
}
|
||||
|
||||
// Tree modification
|
||||
//Add
|
||||
|
||||
@@ -88,9 +88,10 @@ public:
|
||||
|
||||
protected:
|
||||
/* Constructor */
|
||||
TreeByReference(const TreeNode * node) {
|
||||
assert(node != nullptr);
|
||||
setIdentifierAndRetain(node->identifier());
|
||||
TreeByReference(const TreeNode * node) : TreeByReference() {
|
||||
if (node != nullptr) {
|
||||
setIdentifierAndRetain(node->identifier());
|
||||
}
|
||||
}
|
||||
TreeByReference(int nodeIndentifier = TreePool::NoNodeIdentifier) : m_identifier(nodeIndentifier) {}
|
||||
void setIdentifierAndRetain(int newId) {
|
||||
|
||||
@@ -228,12 +228,8 @@ void LayoutNode::scoreCursorInDescendantsVertically (
|
||||
}
|
||||
|
||||
bool LayoutNode::changeGreySquaresOfAllMatrixAncestors(bool add) {
|
||||
LayoutNode * p = parent();
|
||||
if (p == nullptr) {
|
||||
return false;
|
||||
}
|
||||
bool changedSquares = false;
|
||||
LayoutRef currentAncestor = LayoutRef(p);
|
||||
LayoutRef currentAncestor = LayoutRef(parent());
|
||||
while (!currentAncestor.isUninitialized()) {
|
||||
if (currentAncestor.isMatrix()) {
|
||||
if (add) {
|
||||
|
||||
@@ -19,12 +19,6 @@ LayoutCursor LayoutReference::equivalentCursor(LayoutCursor * cursor) {
|
||||
return node()->equivalentCursor(cursor);
|
||||
}
|
||||
|
||||
LayoutReference LayoutReference::root() const {
|
||||
assert(!isUninitialized());
|
||||
LayoutNode * r = node()->root();
|
||||
return r == nullptr ? LayoutReference() : LayoutReference(r);
|
||||
}
|
||||
|
||||
// Tree modification
|
||||
|
||||
void LayoutReference::replaceChild(LayoutRef oldChild, LayoutRef newChild, LayoutCursor * cursor, bool force) {
|
||||
|
||||
Reference in New Issue
Block a user