Fixed integer division by zero error when loading files

This commit is contained in:
Yousef Khadadeh 2026-04-03 14:18:04 +03:00
parent 58fb02f449
commit 97d308268d
19 changed files with 97 additions and 30 deletions

View file

@ -162,7 +162,12 @@ void BrushTool::commit_stroke() {
NetworkingObjects::NetObjOwnerPtr<CanvasComponentContainer>& containerPtr = objInfoBeingEdited->obj;
containerPtr->commit_update(drawP);
containerPtr->send_comp_update(drawP, true);
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
if(containerPtr->get_world_bounds().has_value())
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
else {
auto& components = containerPtr->parentLayer->get_layer().components;
components->erase(components, containerPtr->objInfo);
}
objInfoBeingEdited = nullptr;
}
}

View file

@ -115,7 +115,12 @@ void EllipseDrawTool::commit() {
NetworkingObjects::NetObjOwnerPtr<CanvasComponentContainer>& containerPtr = objInfoBeingEdited->obj;
containerPtr->commit_update(drawP);
containerPtr->send_comp_update(drawP, true);
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
if(containerPtr->get_world_bounds().has_value())
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
else {
auto& components = containerPtr->parentLayer->get_layer().components;
components->erase(components, containerPtr->objInfo);
}
objInfoBeingEdited = nullptr;
}
}

View file

@ -89,7 +89,7 @@ void EraserTool::erase_between_points(const Vector2f& start, const Vector2f& end
drawP.drawCache.node_loop_erase_if_components(bvhNode, [&](auto c) {
if(drawP.layerMan.component_passes_layer_selector(c, drawP.controls.layerSelector) && c->obj->collides_with(drawP.world.drawData.cam.c, cCWorld, cC)) {
erasedComponents.emplace(c);
drawP.drawCache.invalidate_cache_at_aabb(c->obj->get_world_bounds());
drawP.drawCache.invalidate_cache_at_optional_aabb(c->obj->get_world_bounds());
return true;
}
return false;

View file

@ -110,7 +110,12 @@ void LineDrawTool::commit() {
NetworkingObjects::NetObjOwnerPtr<CanvasComponentContainer>& containerPtr = objInfoBeingEdited->obj;
containerPtr->commit_update(drawP);
containerPtr->send_comp_update(drawP, true);
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
if(containerPtr->get_world_bounds().has_value())
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
else {
auto& components = containerPtr->parentLayer->get_layer().components;
components->erase(components, containerPtr->objInfo);
}
objInfoBeingEdited = nullptr;
}
}

View file

@ -119,7 +119,12 @@ void RectDrawTool::commit() {
NetworkingObjects::NetObjOwnerPtr<CanvasComponentContainer>& containerPtr = objInfoBeingEdited->obj;
containerPtr->commit_update(drawP);
containerPtr->send_comp_update(drawP, true);
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
if(containerPtr->get_world_bounds().has_value())
drawP.layerMan.add_undo_place_component(objInfoBeingEdited);
else {
auto& components = containerPtr->parentLayer->get_layer().components;
components->erase(components, containerPtr->objInfo);
}
objInfoBeingEdited = nullptr;
}
}