From bf3b05bc32ae0327fb0a3e833ea0b26846df5c13 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sat, 4 Jan 2025 11:04:24 -0500 Subject: [PATCH] Widgets: Avoid error in PathComboBox --- spyder/widgets/comboboxes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spyder/widgets/comboboxes.py b/spyder/widgets/comboboxes.py index 9fedc32322d..2a5b9944469 100644 --- a/spyder/widgets/comboboxes.py +++ b/spyder/widgets/comboboxes.py @@ -266,7 +266,16 @@ def focusOutEvent(self, event): # https://groups.google.com/group/spyderlib/browse_thread/thread/2257abf530e210bd if not self.is_valid(): lineedit = self.lineEdit() - QTimer.singleShot(50, lambda: lineedit.setText(self.selected_text)) + + # Avoid error when lineedit is no longer available (probably + # because this widget's parent was garbage collected). + # Fixes spyder-ide/spyder#23361 + try: + QTimer.singleShot( + 50, lambda: lineedit.setText(self.selected_text) + ) + except RuntimeError: + pass hide_status = getattr(self.lineEdit(), 'hide_status_icon', None) if hide_status: