diff options
author | crupest <crupest@outlook.com> | 2020-04-02 20:51:19 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-04-02 20:51:19 +0800 |
commit | e38ea3de29ede0e45aab8e595da5e8e3782a396d (patch) | |
tree | 1e0fae414abea5b5cf1fd4fb4194f8c6a9795d7e /src/ui/layout_control.cpp | |
parent | 7dd9494e957af8280f7221395333f886c500edf5 (diff) | |
download | cru-e38ea3de29ede0e45aab8e595da5e8e3782a396d.tar.gz cru-e38ea3de29ede0e45aab8e595da5e8e3782a396d.tar.bz2 cru-e38ea3de29ede0e45aab8e595da5e8e3782a396d.zip |
...
Diffstat (limited to 'src/ui/layout_control.cpp')
-rw-r--r-- | src/ui/layout_control.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/ui/layout_control.cpp b/src/ui/layout_control.cpp index 3b4646e5..cb71da30 100644 --- a/src/ui/layout_control.cpp +++ b/src/ui/layout_control.cpp @@ -2,17 +2,15 @@ #include "cru/ui/window.hpp" -#include <cassert> - namespace cru::ui { LayoutControl::~LayoutControl() { for (const auto child : children_) delete child; } void LayoutControl::AddChild(Control* control, const int position) { - assert(control->GetParent() == nullptr); // The control already has a parent. - assert(!dynamic_cast<Window*>(control)); // Can't add a window as child. - assert(position >= 0 || + Expects(control->GetParent() == nullptr); // The control already has a parent. + Expects(!dynamic_cast<Window*>(control)); // Can't add a window as child. + Expects(position >= 0 || position <= static_cast<int>( this->children_.size())); // The position is out of range. @@ -26,7 +24,7 @@ void LayoutControl::AddChild(Control* control, const int position) { } void LayoutControl::RemoveChild(const int position) { - assert(position >= 0 && + Expects(position >= 0 && position < static_cast<int>( this->children_.size())); // The position is out of range. |