Couple of assertions

This commit is contained in:
2022-11-12 01:38:52 -08:00
parent d81cb5d834
commit 489416a5eb
4 changed files with 5 additions and 1 deletions

View File

@ -35,6 +35,7 @@ void Scene::update() {
SceneItem * Scene::createSceneItem() { SceneItem * Scene::createSceneItem() {
sceneitemid_t id = this->nextId++; sceneitemid_t id = this->nextId++;
auto item = new SceneItem(this, id); auto item = new SceneItem(this, id);
assertNotNull(item);
this->itemsNotInitialized[id] = item; this->itemsNotInitialized[id] = item;
return item; return item;
} }

View File

@ -50,6 +50,7 @@ namespace Dawn {
template<class T> template<class T>
T * addComponent() { T * addComponent() {
auto component = new T(this); auto component = new T(this);
assertNotNull(component);
this->components.push_back(component); this->components.push_back(component);
return component; return component;
} }

View File

@ -11,6 +11,7 @@
using namespace Dawn; using namespace Dawn;
SceneItemComponent::SceneItemComponent(SceneItem *item) { SceneItemComponent::SceneItemComponent(SceneItem *item) {
assertNotNull(item);
this->item = item; this->item = item;
this->transform = &item->transform; this->transform = &item->transform;
} }

View File

@ -8,6 +8,7 @@
using namespace Dawn; using namespace Dawn;
UIComponent::UIComponent(UICanvas *canvas) { UIComponent::UIComponent(UICanvas *canvas) {
assertNotNull(canvas);
this->canvas = canvas; this->canvas = canvas;
} }
@ -141,7 +142,7 @@ void UIComponent::addChild(UIComponent *child) {
} }
void UIComponent::removeChild(UIComponent *child) { void UIComponent::removeChild(UIComponent *child) {
if(child->parent != this) throw "Invalid child"; assertTrue(child->parent != this);
auto it = this->children.begin(); auto it = this->children.begin();
while(it != this->children.end()) { while(it != this->children.end()) {
if(*it == child) { if(*it == child) {