From 1c619d40c66ed6d2c28eb63da6bc56fb497973b9 Mon Sep 17 00:00:00 2001 From: LemonNexus Date: Sat, 14 Feb 2026 18:54:16 +0000 Subject: [PATCH] fix: Add error handling to plugins settings tab BUG: AttributeError when accessing plugin_class.name in settings tab. The error occurred when iterating over discovered plugins and trying to access .name, .version, or .description attributes. While all plugins should have these attributes, there might be edge cases where the plugin_class is not properly formed. FIX: - Added getattr() with defaults for safe attribute access - Added try-except around each plugin row creation - Added error logging for debugging - Gracefully skip broken plugin entries instead of crashing Changes: - _create_plugins_settings_tab() now uses getattr() for all plugin attributes with sensible defaults - Each plugin row is wrapped in try-except for isolation - Errors are logged but don't crash the settings UI --- core/overlay_window.py | 45 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/core/overlay_window.py b/core/overlay_window.py index 12a6eb6..9402ea8 100644 --- a/core/overlay_window.py +++ b/core/overlay_window.py @@ -767,22 +767,39 @@ class OverlayWindow(QMainWindow): if self.plugin_manager: all_plugins = self.plugin_manager.get_all_discovered_plugins() - sorted_plugins = sorted(all_plugins.items(), key=lambda x: x[1].name) + + # Sort by name with error handling + def get_plugin_name(item): + try: + return getattr(item[1], 'name', item[0]) + except: + return item[0] + + sorted_plugins = sorted(all_plugins.items(), key=get_plugin_name) for plugin_id, plugin_class in sorted_plugins: - row = QHBoxLayout() - - cb = QCheckBox(f"{plugin_class.name} (v{plugin_class.version})") - cb.setChecked(self.plugin_manager.is_plugin_enabled(plugin_id)) - cb.setStyleSheet(f"color: {c['text_primary']};") - self.settings_checkboxes[plugin_id] = cb - row.addWidget(cb) - - desc = QLabel(plugin_class.description) - desc.setStyleSheet(f"color: {c['text_muted']}; font-size: {EU_TYPOGRAPHY['size_xs']};") - row.addWidget(desc, 1) - - layout.addLayout(row) + try: + row = QHBoxLayout() + + # Safely get plugin attributes + name = getattr(plugin_class, 'name', plugin_id.split('.')[-1]) + version = getattr(plugin_class, 'version', '?.?.?') + description = getattr(plugin_class, 'description', 'No description') + + cb = QCheckBox(f"{name} (v{version})") + cb.setChecked(self.plugin_manager.is_plugin_enabled(plugin_id)) + cb.setStyleSheet(f"color: {c['text_primary']};") + self.settings_checkboxes[plugin_id] = cb + row.addWidget(cb) + + desc = QLabel(description) + desc.setStyleSheet(f"color: {c['text_muted']}; font-size: {EU_TYPOGRAPHY['size_xs']};") + row.addWidget(desc, 1) + + layout.addLayout(row) + except Exception as e: + print(f"[Overlay] Error creating settings for {plugin_id}: {e}") + continue layout.addStretch() return tab