From 7f29f2d1731fa6f2ce2708d567e69d206f4faf3a Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Sun, 12 Jul 2026 10:11:58 +0200 Subject: [PATCH] fix: replace ComboBoxText.set_active_text() with model-based lookup set_active_text() does not exist in GTK 3.24.x (only in GTK 4.x). When loading a saved config with temperature_controller_type='simulated', the set() method crashed on startup with AttributeError. Added _set_combo_active_text() helper that iterates the model to find the matching entry and calls set_active(index) instead. --- src/damaris/gui/DamarisGUI.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/damaris/gui/DamarisGUI.py b/src/damaris/gui/DamarisGUI.py index 08224d3..32d5ca4 100644 --- a/src/damaris/gui/DamarisGUI.py +++ b/src/damaris/gui/DamarisGUI.py @@ -2396,7 +2396,7 @@ pygobject version %(pygobject)s try: controller_type = config["temperature_controller_type"] if controller_type in ["eurotherm", "simulated"]: - self.config_temp_controller_type_combobox.set_active_text(controller_type) + self._set_combo_active_text(self.config_temp_controller_type_combobox, controller_type) # Update widget visibility based on type self._update_temp_widgets_visibility() except (TypeError, ValueError): @@ -2410,7 +2410,7 @@ pygobject version %(pygobject)s try: baudrate = str(config["temperature_baudrate"]) if baudrate in ["9600", "19200", "38400", "57600", "115200"]: - self.config_temp_baudrate_combobox.set_active_text(baudrate) + self._set_combo_active_text(self.config_temp_baudrate_combobox, baudrate) else: self.config_temp_baudrate_combobox.set_active(0) # Default to 19200 except (TypeError, ValueError): @@ -2496,6 +2496,24 @@ pygobject version %(pygobject)s else: self.config_temp_baudrate_hbox.hide() + def _set_combo_active_text(self, combobox, text): + """ + Set a ComboBoxText's active entry by text. + + Gtk.ComboBoxText.set_active_text() does not exist in GTK 3.24.x, + so we iterate the model to find the matching entry. + """ + if not text: + return + model = combobox.get_model() + if model is None: + return + for i in range(model.iter_n_children(None)): + iter = model.iter_nth_child(None, i) + if iter and model.get(iter, 0)[0] == text: + combobox.set_active(i) + return + def load_config_handler( self, widget ): if self.system_default_filename: self.load_config( self.system_default_filename )