Skip to content

Failure when removing currently selected machine #280

Description

@thehamstermuffin

Describe the bug
When removing all devices, and leaving just one. The settings don't update, since you can't change the device on the dropdown. After restarting it works fine again.

IMPORTANT:
If you are opening an issue related to the connection to your machine, please provide the debug dump!
See here how to save it: https://rayforge.org/docs/troubleshooting/debug

To Reproduce
Steps to reproduce the behavior:

  1. Add 1 machine
  2. Remove all machines except the new one
  3. Close settings.
  4. Try to select current Machine.

Status is not updated, it remains on the previous machine settings

Expected behavior
It should change to the new machine settings.

Screenshots

2026-06-05.18-32-13.mp4

Versions:
1.7.10-52-g96e1a0d0

Extra info:
On further inspection it seems to happen when deleting the currently selected machine

Here is the log when that occurs:

2026-06-05 20:24:49,950 - rayforge.shared.tasker.manager - DEBUG - TaskManager: Adding new task key '140351479403472'.
2026-06-05 20:24:49,951 - rayforge.shared.tasker.task - DEBUG - Task 140351479403472: Entering run method.
2026-06-05 20:24:49,951 - rayforge.machine.models.manager - INFO - Removed machine file: /home/david/.config/rayforge/machines/22b4e78e-839e-434c-bf61-fa5fd8dc9305.yaml
2026-06-05 20:24:49,951 - rayforge.shared.tasker.task - DEBUG - Task 140351479403472: Creating internal asyncio.Task for coro.
2026-06-05 20:24:49,951 - rayforge.shared.tasker.task - DEBUG - Task 140351479403472: Awaiting internal asyncio.Task.
2026-06-05 20:24:49,951 - rayforge.machine.models.controller - INFO - Shutting down controller for machine 'Creality Falcon 10W' (id:22b4e78e-839e-434c-bf61-fa5fd8dc9305)
2026-06-05 20:24:49,951 - rayforge.machine.driver.grbl.grbl_serial - DEBUG - Cleanup initiated.
2026-06-05 20:24:49,951 - rayforge.machine.driver.grbl.grbl_serial - DEBUG - Cleanup completed.
2026-06-05 20:24:49,952 - rayforge.shared.tasker.task - DEBUG - Task 140351479403472: Coro completed successfully.
2026-06-05 20:24:49,952 - rayforge.shared.tasker.task - DEBUG - Task 140351479403472: Run method finished with status 'completed'.
2026-06-05 20:24:49,952 - rayforge.shared.tasker.manager - DEBUG - Cleaning up (asyncio) task '140351479403472' (status: completed).
2026-06-05 20:24:49,953 - rayforge.ui_gtk.machine.machine_dropdown - DEBUG - Syncing machine dropdown model and selection.
2026-06-05 20:24:49,954 - rayforge.core.config - INFO - Current machine 22b4e78e-839e-434c-bf61-fa5fd8dc9305 removed, clearing config
2026-06-05 20:24:49,956 - rayforge.camera.manager - DEBUG - Active machine changed, updating signal connections.
2026-06-05 20:24:49,957 - rayforge.ui_gtk.canvas2d.surface - DEBUG - _update_pipeline_view_context: ppm=(1.58, 1.58), show_travel_moves=False
2026-06-05 20:24:49,958 - rayforge.pipeline.view.view_manager - DEBUG - update_render_context: Context unchanged, skipping
Traceback (most recent call last):
  File "/media/PuiPui/Github/rayforge/rayforge/ui_gtk/settings/machine_settings_page.py", line 195, in _on_delete_confirm_response
    get_context().machine_mgr.remove_machine(machine.id)
  File "/media/PuiPui/Github/rayforge/rayforge/machine/models/manager.py", line 187, in remove_machine
    self.machine_removed.send(self, machine_id=machine_id)
  File "/media/PuiPui/Github/rayforge/.pixi/envs/default/lib/python3.12/site-packages/blinker/base.py", line 249, in send
    result = receiver(sender, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/core/config.py", line 326, in _on_machine_removed
    self.config.set_machine(None)
  File "/media/PuiPui/Github/rayforge/rayforge/core/config.py", line 92, in set_machine
    self.changed.send(self)
  File "/media/PuiPui/Github/rayforge/.pixi/envs/default/lib/python3.12/site-packages/blinker/base.py", line 249, in send
    result = receiver(sender, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/ui_gtk/mainwindow.py", line 1466, in on_config_changed
    self._on_machine_signals_changed(config)
  File "/media/PuiPui/Github/rayforge/rayforge/ui_gtk/mainwindow.py", line 1510, in _on_machine_signals_changed
    self._current_machine.controller.laser_power_changed.disconnect(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/machine/models/machine.py", line 191, in controller
    return self.context.machine_mgr.get_controller(self.id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/machine/models/manager.py", line 67, in get_controller
    raise ValueError(f"No machine found with ID {machine_id}")
ValueError: No machine found with ID 22b4e78e-839e-434c-bf61-fa5fd8dc9305
2026-06-05 20:24:49,961 - rayforge.app - ERROR - Unhandled exception
Traceback (most recent call last):
  File "/media/PuiPui/Github/rayforge/rayforge/ui_gtk/settings/machine_settings_page.py", line 195, in _on_delete_confirm_response
    get_context().machine_mgr.remove_machine(machine.id)
  File "/media/PuiPui/Github/rayforge/rayforge/machine/models/manager.py", line 187, in remove_machine
    self.machine_removed.send(self, machine_id=machine_id)
  File "/media/PuiPui/Github/rayforge/.pixi/envs/default/lib/python3.12/site-packages/blinker/base.py", line 249, in send
    result = receiver(sender, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/core/config.py", line 326, in _on_machine_removed
    self.config.set_machine(None)
  File "/media/PuiPui/Github/rayforge/rayforge/core/config.py", line 92, in set_machine
    self.changed.send(self)
  File "/media/PuiPui/Github/rayforge/.pixi/envs/default/lib/python3.12/site-packages/blinker/base.py", line 249, in send
    result = receiver(sender, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/ui_gtk/mainwindow.py", line 1466, in on_config_changed
    self._on_machine_signals_changed(config)
  File "/media/PuiPui/Github/rayforge/rayforge/ui_gtk/mainwindow.py", line 1510, in _on_machine_signals_changed
    self._current_machine.controller.laser_power_changed.disconnect(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/machine/models/machine.py", line 191, in controller
    return self.context.machine_mgr.get_controller(self.id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/PuiPui/Github/rayforge/rayforge/machine/models/manager.py", line 67, in get_controller
    raise ValueError(f"No machine found with ID {machine_id}")
ValueError: No machine found with ID 22b4e78e-839e-434c-bf61-fa5fd8dc9305

found that by commenting or placing a try-catch on this lines it stops happening (thats the closes I could come to the solution)

on rayforge/ui_gtk/mainwindow.py line 1507

        try:
            self._current_machine.controller.laser_power_changed.disconnect(
                self._on_laser_power_changed
            )
        except ValueError:
            pass

and removing line 481 on rayforge/ui_gtk/doceditor/bottom_panel.py

Hope that helps

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions