Skip to content

Commit

Permalink
Fix memory leak where the project remained referenced in BaseDraw eve…
Browse files Browse the repository at this point in the history
…n when its tab was closed

Another memory leak remains in Recorder.gd, where the first project forever remains referenced in memory, until the user changes the project from the option button. Perhaps we should remove that option button completely and always record the current project, that also sounds like the intended behavior to me.
  • Loading branch information
OverloadedOrama committed Nov 3, 2024
1 parent e2971a8 commit 8beb79a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Tools/BaseDraw.gd
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ func draw_tool(pos: Vector2i) -> void:

func draw_end(pos: Vector2i) -> void:
super.draw_end(pos)
_stroke_project = null
_stroke_images = []
_brush_size_dynamics = _brush_size
if Tools.dynamics_size != Tools.Dynamics.NONE:
_brush_size_dynamics = Tools.brush_size_min
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/DesignTools/Eraser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func draw_move(pos_i: Vector2i) -> void:

func draw_end(pos: Vector2i) -> void:
pos = snap_position(pos)
super.draw_end(pos)
if _picking_color:
super.draw_end(pos)
return

if _draw_line:
Expand All @@ -105,6 +105,7 @@ func draw_end(pos: Vector2i) -> void:
draw_fill_gap(_line_start, _line_end)
_draw_line = false

super.draw_end(pos)
commit_undo()
SteamManager.set_achievement("ACH_ERASE_PIXEL")
cursor_text = ""
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/DesignTools/Pencil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ func draw_move(pos_i: Vector2i) -> void:

func draw_end(pos: Vector2i) -> void:
pos = snap_position(pos)
super.draw_end(pos)
if _picking_color:
super.draw_end(pos)
return

if _draw_line:
Expand Down Expand Up @@ -194,6 +194,7 @@ func draw_end(pos: Vector2i) -> void:
draw_tool(v)

_fill_inside_rect = Rect2i()
super.draw_end(pos)
commit_undo()
cursor_text = ""
update_random_image()
Expand Down
3 changes: 2 additions & 1 deletion src/Tools/DesignTools/Shading.gd
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ func draw_move(pos_i: Vector2i) -> void:

func draw_end(pos: Vector2i) -> void:
pos = snap_position(pos)
super.draw_end(pos)
if _picking_color:
super.draw_end(pos)
return

if _draw_line:
Expand All @@ -304,6 +304,7 @@ func draw_end(pos: Vector2i) -> void:
draw_fill_gap(_line_start, _line_end)
_draw_line = false

super.draw_end(pos)
commit_undo()
cursor_text = ""
update_random_image()
Expand Down

0 comments on commit 8beb79a

Please sign in to comment.