diff --git a/src/graphics/ui/elements/InlineFrame.cpp b/src/graphics/ui/elements/InlineFrame.cpp index eeef50e47..8699fd70b 100644 --- a/src/graphics/ui/elements/InlineFrame.cpp +++ b/src/graphics/ui/elements/InlineFrame.cpp @@ -25,8 +25,12 @@ void InlineFrame::setDocument(const std::shared_ptr& document) { if (document == nullptr) { return; } + auto newRoot = document->getRoot(); + if (newRoot->hasParent()) { + return; + } this->document = document; - this->root = document->getRoot(); + this->root = std::move(newRoot); add(root); root->setSize(size); diff --git a/src/graphics/ui/elements/UINode.cpp b/src/graphics/ui/elements/UINode.cpp index 918d30b65..3f099d2b8 100644 --- a/src/graphics/ui/elements/UINode.cpp +++ b/src/graphics/ui/elements/UINode.cpp @@ -60,6 +60,10 @@ bool UINode::isHover() const { return hover; } +bool UINode::hasParent() const { + return parent != nullptr; +} + void UINode::setParent(UINode* node) { parent = node; } diff --git a/src/graphics/ui/elements/UINode.hpp b/src/graphics/ui/elements/UINode.hpp index 4f6145f08..f22487323 100644 --- a/src/graphics/ui/elements/UINode.hpp +++ b/src/graphics/ui/elements/UINode.hpp @@ -176,6 +176,7 @@ namespace gui { void setMouseOver(bool flag); virtual void setParent(UINode* node); + bool hasParent() const; UINode* getParent() const; std::shared_ptr getParentShared() const;