From 076400e38433617dbcf493d4ec64586c1a7f5530 Mon Sep 17 00:00:00 2001 From: "Lumberbot (aka Jack)" <39504233+meeseeksmachine@users.noreply.github.com> Date: Sat, 4 Jan 2025 09:56:56 -0800 Subject: [PATCH] Backport PR #23410 on branch 6.x (PR: Avoid error in `PathComboBox` (Widgets)) (#23411) --- 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: