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:
parent
721b5e14a6
commit
1c619d40c6
|
|
@ -767,22 +767,39 @@ class OverlayWindow(QMainWindow):
|
||||||
|
|
||||||
if self.plugin_manager:
|
if self.plugin_manager:
|
||||||
all_plugins = self.plugin_manager.get_all_discovered_plugins()
|
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:
|
for plugin_id, plugin_class in sorted_plugins:
|
||||||
row = QHBoxLayout()
|
try:
|
||||||
|
row = QHBoxLayout()
|
||||||
|
|
||||||
cb = QCheckBox(f"{plugin_class.name} (v{plugin_class.version})")
|
# Safely get plugin attributes
|
||||||
cb.setChecked(self.plugin_manager.is_plugin_enabled(plugin_id))
|
name = getattr(plugin_class, 'name', plugin_id.split('.')[-1])
|
||||||
cb.setStyleSheet(f"color: {c['text_primary']};")
|
version = getattr(plugin_class, 'version', '?.?.?')
|
||||||
self.settings_checkboxes[plugin_id] = cb
|
description = getattr(plugin_class, 'description', 'No description')
|
||||||
row.addWidget(cb)
|
|
||||||
|
|
||||||
desc = QLabel(plugin_class.description)
|
cb = QCheckBox(f"{name} (v{version})")
|
||||||
desc.setStyleSheet(f"color: {c['text_muted']}; font-size: {EU_TYPOGRAPHY['size_xs']};")
|
cb.setChecked(self.plugin_manager.is_plugin_enabled(plugin_id))
|
||||||
row.addWidget(desc, 1)
|
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()
|
layout.addStretch()
|
||||||
return tab
|
return tab
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue