Skip to content

Commit

Permalink
Fix crash due to division by zero when locking two or three ValueSlid…
Browse files Browse the repository at this point in the history
…ers and one of them has the value of 0 and the user attempts to change it
  • Loading branch information
OverloadedOrama committed Mar 16, 2024
1 parent 9a5eb97 commit 3b8c63c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Built using Godot 3.5.2
- Optimize canvas drawing by only updating it when the image(s) have changed. [ac6a4db43d9296ebc03e639d8199dd3878a25d86](https://github.com/Orama-Interactive/Pixelorama/commit/ac6a4db43d9296ebc03e639d8199dd3878a25d86)
- Fix bug where using shortcuts to switch between frames also moved the selection, causing deletions.
- Pxo files can now be loaded from the Open menu option in the Web version. [3dcc51705a999145e53a8e6d4de217dc03b0f147](https://github.com/Orama-Interactive/Pixelorama/commit/3dcc51705a999145e53a8e6d4de217dc03b0f147)
- Fixed crash due to division by zero when locking two or three ValueSliders, and one of them has the value of 0 and the user attempts to change it.
- Fixed exporting selected layers not including the non-selected frames.
- The ellipse tool no longer produces gaps with large sizes. [4f3a7a305a264e0d2fe86c201af76eca4b2fea0a](https://github.com/Orama-Interactive/Pixelorama/commit/4f3a7a305a264e0d2fe86c201af76eca4b2fea0a)
- Fix "visible layers" option on the export dialog producing wrong results. [346d1f071a8c6b1defb1072d39aea9c642f1ef59](https://github.com/Orama-Interactive/Pixelorama/commit/346d1f071a8c6b1defb1072d39aea9c642f1ef59)
Expand Down
2 changes: 1 addition & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ config/icon="res://assets/graphics/icons/icon.png"
config/macos_native_icon="res://assets/graphics/icons/icon.icns"
config/windows_native_icon="res://assets/graphics/icons/icon.ico"
config/custom_user_dir_name.X11="pixelorama"
config/Version="v0.11.4-rc3"
config/Version="v0.11.4-rc2"
config/ExtensionsAPI_Version=3
config/Pxo_Version=2

Expand Down
6 changes: 4 additions & 2 deletions src/UI/Nodes/ValueSliderV2.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ func _gcd(a: int, b: int) -> int:
func _on_X_value_changed(val: float) -> void:
value.x = val
if _locked_ratio:
self.value.y = max(min_value.y, (value.x / ratio.x) * ratio.y)
if not is_zero_approx(ratio.x):
self.value.y = max(min_value.y, (value.x / ratio.x) * ratio.y)
if _can_emit_signal:
emit_signal("value_changed", value)


func _on_Y_value_changed(val: float) -> void:
value.y = val
if _locked_ratio:
self.value.x = max(min_value.x, (value.y / ratio.y) * ratio.x)
if not is_zero_approx(ratio.y):
self.value.x = max(min_value.x, (value.y / ratio.y) * ratio.x)
if _can_emit_signal:
emit_signal("value_changed", value)

Expand Down
15 changes: 9 additions & 6 deletions src/UI/Nodes/ValueSliderV3.gd
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,29 @@ func _gcd(a: int, b: int) -> int:
func _on_X_value_changed(val: float) -> void:
value.x = val
if _locked_ratio:
self.value.y = max(min_value.y, (value.x / ratio.x) * ratio.y)
self.value.z = max(min_value.z, (value.x / ratio.x) * ratio.z)
if not is_zero_approx(ratio.x):
self.value.y = max(min_value.y, (value.x / ratio.x) * ratio.y)
self.value.z = max(min_value.z, (value.x / ratio.x) * ratio.z)
if _can_emit_signal:
emit_signal("value_changed", value)


func _on_Y_value_changed(val: float) -> void:
value.y = val
if _locked_ratio:
self.value.x = max(min_value.x, (value.y / ratio.y) * ratio.x)
self.value.z = max(min_value.z, (value.y / ratio.y) * ratio.z)
if not is_zero_approx(ratio.y):
self.value.x = max(min_value.x, (value.y / ratio.y) * ratio.x)
self.value.z = max(min_value.z, (value.y / ratio.y) * ratio.z)
if _can_emit_signal:
emit_signal("value_changed", value)


func _on_Z_value_changed(val: float) -> void:
value.z = val
if _locked_ratio:
self.value.x = max(min_value.x, (value.z / ratio.z) * ratio.x)
self.value.y = max(min_value.y, (value.z / ratio.z) * ratio.y)
if not is_zero_approx(ratio.z):
self.value.x = max(min_value.x, (value.z / ratio.z) * ratio.x)
self.value.y = max(min_value.y, (value.z / ratio.z) * ratio.y)
if _can_emit_signal:
emit_signal("value_changed", value)

Expand Down

0 comments on commit 3b8c63c

Please sign in to comment.