Fixed memory issue when using tools

This commit is contained in:
Yousef Khadadeh 2025-12-30 23:12:30 +03:00
parent caf99a8675
commit 9d752af00c
7 changed files with 7 additions and 7 deletions

View file

@ -31,7 +31,7 @@ class EditTool : public DrawingProgramToolBase {
std::unique_ptr<DrawingProgramEditToolBase> compEditTool;
std::vector<HandleData> pointHandles;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited = nullptr;
HandleData* pointDragging = nullptr;
std::any prevData;
};

View file

@ -45,7 +45,7 @@ void EllipseDrawTool::switch_tool(DrawingProgramToolType newTool) {
}
void EllipseDrawTool::tool_update() {
if(objInfoBeingEdited) {
if(!objInfoBeingEdited) {
if(drawP.controls.leftClick && drawP.layerMan.is_a_layer_being_edited()) {
CanvasComponentContainer* newContainer = new CanvasComponentContainer(drawP.world.netObjMan, CanvasComponentType::ELLIPSE);
EllipseCanvasComponent& newEllipse = static_cast<EllipseCanvasComponent&>(newContainer->get_comp());

View file

@ -22,5 +22,5 @@ class EllipseDrawTool : public DrawingProgramToolBase {
Vector2f startAt;
int fillStrokeMode = 1;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited = nullptr;
};

View file

@ -43,7 +43,7 @@ void RectDrawTool::switch_tool(DrawingProgramToolType newTool) {
}
void RectDrawTool::tool_update() {
if(objInfoBeingEdited) {
if(!objInfoBeingEdited) {
if(drawP.controls.leftClick && drawP.layerMan.is_a_layer_being_edited()) {
CanvasComponentContainer* newContainer = new CanvasComponentContainer(drawP.world.netObjMan, CanvasComponentType::RECTANGLE);
RectangleCanvasComponent& newRectangle = static_cast<RectangleCanvasComponent&>(newContainer->get_comp());

View file

@ -22,5 +22,5 @@ class RectDrawTool : public DrawingProgramToolBase {
Vector2f startAt;
float relativeRadiusWidth = 10.0f;
int fillStrokeMode = 1;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited = nullptr;
};

View file

@ -42,7 +42,7 @@ void TextBoxTool::switch_tool(DrawingProgramToolType newTool) {
}
void TextBoxTool::tool_update() {
if(objInfoBeingEdited) {
if(!objInfoBeingEdited) {
if(drawP.controls.leftClick && drawP.layerMan.is_a_layer_being_edited()) {
startAt = drawP.world.main.input.mouse.pos;
endAt = startAt;

View file

@ -22,5 +22,5 @@ class TextBoxTool : public DrawingProgramToolBase {
Vector2f startAt;
Vector2f endAt;
int drawStage = 0;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited;
CanvasComponentContainer::ObjInfo* objInfoBeingEdited = nullptr;
};