diff --git a/main.py b/main.py index 1450b14..422f128 100644 --- a/main.py +++ b/main.py @@ -2589,12 +2589,6 @@ class MainWindow(QtWidgets.QMainWindow): for widget in QtWidgets.QApplication.allWidgets(): if hasattr(widget, 'img_preview') and hasattr(widget.img_preview, 'clear'): widget.img_preview.clear() - # Disconnect any remaining signal connections - if hasattr(widget, 'disconnect'): - try: - widget.disconnect() - except: - pass except: pass @@ -4363,10 +4357,16 @@ class MainWindow(QtWidgets.QMainWindow): # Update global delay controls if self.current_scenario: # Temporarily disconnect signals to prevent triggering auto-save during loading - self.before_action_spinbox.valueChanged.disconnect() - self.after_action_spinbox.valueChanged.disconnect() - self.before_step_spinbox.valueChanged.disconnect() - self.after_step_spinbox.valueChanged.disconnect() + for sig in ( + self.before_action_spinbox.valueChanged, + self.after_action_spinbox.valueChanged, + self.before_step_spinbox.valueChanged, + self.after_step_spinbox.valueChanged, + ): + try: + sig.disconnect() + except Exception: + pass # Load global delay settings global_delay = self.current_scenario.global_delay @@ -4381,11 +4381,17 @@ class MainWindow(QtWidgets.QMainWindow): self.before_step_spinbox.valueChanged.connect(self._on_global_delay_changed) self.after_step_spinbox.valueChanged.connect(self._on_global_delay_changed) else: - # Reset to default values when no scenario is selected - self.before_action_spinbox.valueChanged.disconnect() - self.after_action_spinbox.valueChanged.disconnect() - self.before_step_spinbox.valueChanged.disconnect() - self.after_step_spinbox.valueChanged.disconnect() + # Reset to default values when no scenario is selected (safe disconnects) + for sig in ( + self.before_action_spinbox.valueChanged, + self.after_action_spinbox.valueChanged, + self.before_step_spinbox.valueChanged, + self.after_step_spinbox.valueChanged, + ): + try: + sig.disconnect() + except Exception: + pass self.before_action_spinbox.setValue(0.0) self.after_action_spinbox.setValue(0.0) self.before_step_spinbox.setValue(0.0)