mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 18:27:05 +08:00
ModuleParams: remove parent in destructor
This allows for dynamic deletion of children objects (in most cases this is not used). Uses ~100B memory.
This commit is contained in:
@@ -61,9 +61,14 @@ public:
|
|||||||
if (parent) {
|
if (parent) {
|
||||||
parent->_children.add(this);
|
parent->_children.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ModuleParams() = default;
|
virtual ~ModuleParams()
|
||||||
|
{
|
||||||
|
if (_parent) { _parent->_children.remove(this); }
|
||||||
|
}
|
||||||
|
|
||||||
// Disallow copy construction and move assignment.
|
// Disallow copy construction and move assignment.
|
||||||
ModuleParams(const ModuleParams &) = delete;
|
ModuleParams(const ModuleParams &) = delete;
|
||||||
@@ -93,4 +98,5 @@ protected:
|
|||||||
private:
|
private:
|
||||||
/** @list _children The module parameter list of inheriting classes. */
|
/** @list _children The module parameter list of inheriting classes. */
|
||||||
List<ModuleParams *> _children;
|
List<ModuleParams *> _children;
|
||||||
|
ModuleParams *_parent{nullptr};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user