diff options
Diffstat (limited to 'src/ui/layout_control.cpp')
-rw-r--r-- | src/ui/layout_control.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/ui/layout_control.cpp b/src/ui/layout_control.cpp index d2b430dd..c0c4a7fe 100644 --- a/src/ui/layout_control.cpp +++ b/src/ui/layout_control.cpp @@ -3,24 +3,14 @@ #include "window.hpp" namespace cru::ui { -void ControlAddChildCheck(Control* control) { - if (control->GetParent() != nullptr) - throw std::invalid_argument("The control already has a parent."); - - if (dynamic_cast<Window*>(control)) - throw std::invalid_argument("Can't add a window as child."); -} - LayoutControl::~LayoutControl() { for (const auto child : children_) delete child; } void LayoutControl::AddChild(Control* control, const int position) { - ControlAddChildCheck(control); - - if (position < 0 || static_cast<decltype(children_.size())>(position) > - this->children_.size()) - throw std::invalid_argument("The position is out of range."); + 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 || position <= this->children_.size()); // The position is out of range. children_.insert(this->children_.cbegin() + position, control); @@ -31,9 +21,8 @@ void LayoutControl::AddChild(Control* control, const int position) { } void LayoutControl::RemoveChild(const int position) { - if (position < 0 || static_cast<decltype(this->children_.size())>(position) >= - this->children_.size()) - throw std::invalid_argument("The position is out of range."); + assert(position >= 0 && + position < this->children_.size()); // The position is out of range. const auto i = children_.cbegin() + position; const auto child = *i; |