From 9b603b2d8c1728cc685b87a267c7f83e27c3cca3 Mon Sep 17 00:00:00 2001 From: H3xano Date: Fri, 29 May 2026 11:05:09 +0200 Subject: [PATCH] passwordEntry: guard against None layout sources When the screensaver fails to connect to Cinnamon (logged as 'Failed to connect to Cinnamon'), lockscreen_layout_source and system_layout_source remain None. Three methods then crash dereferencing them: - restore_original_layout(): AttributeError on .index - on_draw(): AttributeError on .flag_name / .short_name - update_layout_icon(): AttributeError on .display_name Add early-return guards in all three methods. Reproduces on: Cinnamon 6.6.x, NVIDIA GPU, single keyboard layout (us), after unlock from screensaver. --- src/passwordEntry.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/passwordEntry.py b/src/passwordEntry.py index 7a2c0825..824d6801 100644 --- a/src/passwordEntry.py +++ b/src/passwordEntry.py @@ -59,6 +59,8 @@ def on_draw(self, widget, cr, data=None): height = icon_rect.height - 4 handled = False + if self.lockscreen_layout_source is None: + return False if settings.get_show_flags(): ui_scale = self.get_scale_factor() @@ -203,6 +205,8 @@ def update_layout_icon(self): also ensures a redraw at the correct time to update the flag image. """ self.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, "screensaver-blank") + if self.lockscreen_layout_source is None: + return self.set_icon_tooltip_text(Gtk.EntryIconPosition.PRIMARY, self.lockscreen_layout_source.display_name) def on_destroy(self, widget, data=None): @@ -239,6 +243,8 @@ def restore_original_layout(self): Called when the unlock dialog is destroyed, restores the group that was active before the screensaver was activated. """ + if self.lockscreen_layout_source is None or self.system_layout_source is None: + return if settings.get_kb_group() != self.lockscreen_layout_source.index: settings.set_kb_group(self.lockscreen_layout_source.index)