Skip to content

Commit

Permalink
cleanup and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
m0dB authored and m0dB committed Nov 2, 2024
1 parent 8b25d13 commit a57b823
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rendergraph/examples/sg_example/customitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CustomItem : public QQuickItem {

public:
explicit CustomItem(QQuickItem* parent = nullptr);
~CustomItem();
~CustomItem() override;

protected:
QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*) override;
Expand Down
11 changes: 11 additions & 0 deletions src/rendergraph/opengl/rendergraph/nodeinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,21 @@ template<class T_Node>
class NodeInterface : public T_Node {
public:
void appendChildNode(std::unique_ptr<BaseNode> pNode) {
// Transfers ownership to this.
BaseNode* pRawNode = pNode.release();
// Note: Ideally we would use unique_ptrs internally, but
// Qt uses raw pointers for QSGNode hierarchy. For simplicity
// we mimic this.

T_Node::appendChildNode(pRawNode);
}

std::unique_ptr<BaseNode> detachChildNode(BaseNode* pNode) {
// After removeChildNode, the caller has the responsibility
// to deal with the child node. By returning a unique_ptr
// we preoprtly transfer ownership to the caller (which
// can result in deleting pNode if the caller doesn't
// take the unique_ptr).
T_Node::removeChildNode(pNode);
return std::unique_ptr<BaseNode>(pNode);
}
Expand Down

0 comments on commit a57b823

Please sign in to comment.