fix: wrap setStyleSheet in try/except to prevent stylesheet crash

- Add inner try/except around setStyleSheet calls
- Catch and ignore stylesheet parsing errors
- Prevents 'Could not parse stylesheet' crash
This commit is contained in:
LemonNexus 2026-02-10 14:22:38 +00:00
parent b14888dc97
commit 0a6e4358de
1 changed files with 8 additions and 2 deletions

View File

@ -789,7 +789,10 @@ class HUDOverlay(QWidget):
profit = self._stats.profit_loss profit = self._stats.profit_loss
color = "#7FFF7F" if profit >= 0 else "#FF7F7F" color = "#7FFF7F" if profit >= 0 else "#FF7F7F"
self.profit_label.setText(f"{profit:+.2f} PED") self.profit_label.setText(f"{profit:+.2f} PED")
try:
self.profit_label.setStyleSheet(f"font-size: 18px; font-weight: bold; color: {color};") self.profit_label.setStyleSheet(f"font-size: 18px; font-weight: bold; color: {color};")
except Exception:
pass # Stylesheet error, ignore
except RuntimeError: except RuntimeError:
pass pass
@ -804,7 +807,10 @@ class HUDOverlay(QWidget):
else: else:
color = "#FF7F7F" color = "#FF7F7F"
self.return_label.setText(f"{ret:.1f}%") self.return_label.setText(f"{ret:.1f}%")
try:
self.return_label.setStyleSheet(f"font-size: 16px; font-weight: bold; color: {color};") self.return_label.setStyleSheet(f"font-size: 16px; font-weight: bold; color: {color};")
except Exception:
pass # Stylesheet error, ignore
except RuntimeError: except RuntimeError:
pass pass