Ulm-IQO / qudi-core

A framework for modular measurement applications.
GNU General Public License v3.0
38 stars 21 forks source link

[Bug] SystemTrayIcon error #123

Closed TobiasSpohn closed 1 week ago

TobiasSpohn commented 1 month ago

Version

Development

What is affected by the bug?

With PR #118 loading any GUI module will cause ValueError: Action "time_series_gui" already exists in system tray.

When does the bug occur?

Activation of any GUI module, when changing the module state and therefore entering the _tray_module_action_changed method.

How do we replicate the issue?

Expected behavior

no error is displayed

Relevant log output

2024-10-30 14:53:28 warning qudi.core.gui.gui tray_module_action_changed, base='gui', module_name='time_series_gui', state='deactivated'
2024-10-30 14:53:28 info qudi.core.modulemanager Activating gui module "time_series.time_series_gui.TimeSeriesGui"
2024-10-30 14:53:29 warning qudi.core.gui.gui tray_module_action_changed, base='logic', module_name='time_series_reader_logic', state='deactivated'
2024-10-30 14:53:29 info qudi.core.modulemanager Activating logic module "time_series_reader_logic.TimeSeriesReaderLogic"
2024-10-30 14:53:29 warning qudi.core.gui.gui tray_module_action_changed, base='hardware', module_name='instream_dummy', state='deactivated'
2024-10-30 14:53:29 info qudi.core.modulemanager Activating hardware module "dummy.data_instream_dummy.InStreamDummy"
2024-10-30 14:53:29 warning qudi.core.gui.gui tray_module_action_changed, base='hardware', module_name='instream_dummy', state='idle'
2024-10-30 14:53:29 warning qudi.core.gui.gui tray_module_action_changed, base='hardware', module_name='instream_dummy', state='idle'
2024-10-30 14:53:29 debug qudi.core.threadmanager Creating thread: "mod-logic-time_series_reader_logic".
2024-10-30 14:53:29 warning qudi.core.gui.gui tray_module_action_changed, base='logic', module_name='time_series_reader_logic', state='idle'
2024-10-30 14:53:29 warning qudi.core.gui.gui tray_module_action_changed, base='gui', module_name='time_series_gui', state='idle'
2024-10-30 14:53:29 warning qudi.core.gui.gui add_action, label='time_series_gui'
2024-10-30 14:53:29 warning qudi.core.gui.gui tray_module_action_changed, base='gui', module_name='time_series_gui', state='idle'
2024-10-30 14:53:29 warning qudi.core.gui.gui add_action, label='time_series_gui'
2024-10-30 14:53:29 error qudi.core.gui.gui.SystemTrayIcon 
Traceback (most recent call last):
  File "C:\Users\Tobias Spohn\qudi\qudi-core\src\qudi\core\gui\gui.py", line 393, in _tray_module_action_changed
    self.system_tray_icon.add_action(module_name, module_inst.show)
  File "C:\Users\Tobias Spohn\qudi\qudi-core\src\qudi\core\gui\gui.py", line 89, in add_action
    raise ValueError(f'Action "{label}" already exists in system tray.')
ValueError: Action "time_series_gui" already exists in system tray.
2024-10-30 14:53:30 warning qudi.core.gui.gui tray_module_action_changed, base='logic', module_name='time_series_reader_logic', state='idle'

Additional Comments

I added the warning messages so one can see when _tray_module_action_changed is called and when it actually enters the add_action method that throws the error. It seems like the _tray_module_action_changed method is being called twice when the GUI module changes its state from deactivated to idle

timoML commented 1 week ago

Can this be considered resolved? @TobiasSpohn

TobiasSpohn commented 1 week ago

Sure, sorry forgot to close it.