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
This commit is contained in:
LemonNexus 2026-02-14 18:54:16 +00:00
parent 721b5e14a6
commit 1c619d40c6
1 changed files with 31 additions and 14 deletions

View File

@ -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()
try:
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)
# 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')
desc = QLabel(plugin_class.description)
desc.setStyleSheet(f"color: {c['text_muted']}; font-size: {EU_TYPOGRAPHY['size_xs']};")
row.addWidget(desc, 1)
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)
layout.addLayout(row)
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