Skip to content

Commit

Permalink
Fixed crash when universe deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Sherwin committed Apr 9, 2024
1 parent 024b873 commit 8371492
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Components/Virtual Fixture/Virtual_fixture.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func set_highlighted(highlight):
else:
$"Color Box".get_theme_stylebox("panel").border_color = Color.BLACK

func delete():
func delete(_fixture = null):
self.get_parent()._selected_virtual_fixtures.erase(self)
self.queue_free()

Expand Down
2 changes: 1 addition & 1 deletion Panels/Fixtures/Fixtures.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func _ready() -> void:
Core.fixture_selection_changed.connect(self._reload_fixtures)


func _reload_fixtures(_scene=null) -> void:
func _reload_fixtures(_fixture=null) -> void:
## Reload the list of fixtures

self.get_node(item_list_view).remove_all()
Expand Down
4 changes: 2 additions & 2 deletions core/components/EngineComponent.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class_name EngineComponent extends Object
signal user_meta_changed(origin: EngineComponent, key: String, value: Variant) ## Emitted when an item is added, edited, or deleted from user_meta, if no value is present it meanes that the key has been deleted
signal name_changed(new_name: String) ## Emitted when the name of this object has changed
signal selected(is_selected: bool)
signal delete_request()
signal delete_request(origin: EngineComponent)

var uuid: String = "" ## Uuid of the current component
var name: String = "": set = _set_name ## The name of this object, only use when displaying to users, do not use it as a reference
Expand Down Expand Up @@ -91,4 +91,4 @@ func serialize_meta() -> Dictionary:


func delete() -> void:
delete_request.emit()
delete_request.emit(self)
11 changes: 11 additions & 0 deletions core/components/Fixture.gd
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ func recompile_data() -> void:
universe.set_data(_compiled_dmx_data)


func delete() -> void:
delete_request.emit(self)

var empty_data: Dictionary = {}

for i in _compiled_dmx_data:
empty_data[i] = 0

universe.set_data(empty_data)


func _set_color(color: Color) -> void:
if "ColorIntensityRed" in channels:
_compiled_dmx_data[int(channels.find("ColorIntensityRed") + channel)] = color.r8
Expand Down
11 changes: 5 additions & 6 deletions core/components/Universe.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class_name Universe extends EngineComponent

signal fixture_name_changed(fixture: Fixture, new_name: String)
signal fixtures_added(fixtures: Array[Fixture])
signal fixtures_deleted(fixture_uuids: Array[String])
signal fixtures_deleted(fixture_uuids: Array)

signal outputs_added(outputs: Array[DataIOPlugin])
signal outputs_removed(output_uuids: Array[String])
Expand Down Expand Up @@ -104,8 +104,7 @@ func remove_fixture(fixture: Fixture, no_signal: bool = false):
fixture.free()

if not no_signal:
var uuids: Array[String] = [fixture_uuid]
fixtures_deleted.emit(uuids)
fixtures_deleted.emit([fixture_uuid])


func remove_fixtures(fixtures_to_remove: Array, no_signal: bool = false) -> void:
Expand All @@ -127,10 +126,10 @@ func is_channel_used(channels: Array) -> bool:


func delete():
## Called when this universe is about to be deleted, it will remove all outputs from this universe
## Called when this universe is about to be deleted, it will remove all outputs and fixtures from this universe

for output in outputs.values():
remove_output(output)
remove_fixtures(fixtures.values())
remove_outputs(outputs.values())


func set_data(data: Dictionary):
Expand Down
4 changes: 2 additions & 2 deletions core/engine/Engine.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ signal universe_selection_changed(selected_universes: Array[Universe])

signal fixture_name_changed(fixture: Fixture, new_name)
signal fixture_added(fixture: Array[Fixture])
signal fixture_removed(fixture_uuid: Array[String])
signal fixture_removed(fixture_uuid: Array)
signal fixture_selection_changed(selected_fixtures: Array[Fixture])

signal scenes_added(scene: Array[Scene])
Expand Down Expand Up @@ -140,7 +140,7 @@ func _connect_universe_signals(universe: Universe):
)

universe.fixtures_deleted.connect(
func(fixture_uuids: Array[String]):
func(fixture_uuids: Array):
fixture_removed.emit(fixture_uuids)
)

Expand Down
2 changes: 1 addition & 1 deletion core/io_plugins/output_plugins/ArtNetOutput.gd
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ func delete():

func send_packet() -> void:

print(_current_data)
if not _current_data:
return

print(_current_data)

# Construct Art-Net packet
var packet = PackedByteArray()
Expand Down

0 comments on commit 8371492

Please sign in to comment.