fix: HUD rebuild stability and end_session compatibility
- Add end_session() as alias for stop_session() for backward compatibility - Use delayed rebuild with QTimer.singleShot to avoid UI glitches - Add container.show() at end of _setup_ui to ensure visibility - Add error handling in _do_rebuild for recovery
This commit is contained in:
parent
f9b4d9a44b
commit
4c084bd0cd
|
|
@ -467,6 +467,9 @@ class HUDOverlay(QWidget):
|
||||||
|
|
||||||
layout.addLayout(footer)
|
layout.addLayout(footer)
|
||||||
|
|
||||||
|
# Ensure container is visible
|
||||||
|
self.container.show()
|
||||||
|
|
||||||
def _get_stylesheet(self) -> str:
|
def _get_stylesheet(self) -> str:
|
||||||
"""Get stylesheet based on compact mode."""
|
"""Get stylesheet based on compact mode."""
|
||||||
font_size = "11px" if self.hud_config.compact_mode else "12px"
|
font_size = "11px" if self.hud_config.compact_mode else "12px"
|
||||||
|
|
@ -517,14 +520,28 @@ class HUDOverlay(QWidget):
|
||||||
|
|
||||||
def _rebuild_ui(self):
|
def _rebuild_ui(self):
|
||||||
"""Rebuild UI with current config."""
|
"""Rebuild UI with current config."""
|
||||||
# Delete old container and recreate
|
# Hide first to avoid visual glitch
|
||||||
|
self.hide()
|
||||||
|
|
||||||
|
# Delete old container
|
||||||
if hasattr(self, 'container') and self.container:
|
if hasattr(self, 'container') and self.container:
|
||||||
self.container.deleteLater()
|
self.container.deleteLater()
|
||||||
self.container = None
|
self.container = None
|
||||||
|
|
||||||
# Rebuild everything
|
# Small delay to ensure cleanup
|
||||||
|
from PyQt6.QtCore import QTimer
|
||||||
|
QTimer.singleShot(10, self._do_rebuild)
|
||||||
|
|
||||||
|
def _do_rebuild(self):
|
||||||
|
"""Actually rebuild the UI."""
|
||||||
|
try:
|
||||||
self._setup_ui()
|
self._setup_ui()
|
||||||
self._refresh_display()
|
self._refresh_display()
|
||||||
|
self.show()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error rebuilding HUD: {e}")
|
||||||
|
# Try to recover
|
||||||
|
self.show()
|
||||||
|
|
||||||
# === Session Management ===
|
# === Session Management ===
|
||||||
|
|
||||||
|
|
@ -552,6 +569,10 @@ class HUDOverlay(QWidget):
|
||||||
self.status_label.setText("● Live")
|
self.status_label.setText("● Live")
|
||||||
self.status_label.setStyleSheet("color: #7FFF7F; font-weight: bold;")
|
self.status_label.setStyleSheet("color: #7FFF7F; font-weight: bold;")
|
||||||
|
|
||||||
|
def end_session(self) -> None:
|
||||||
|
"""Alias for stop_session for backward compatibility."""
|
||||||
|
self.stop_session()
|
||||||
|
|
||||||
def stop_session(self) -> None:
|
def stop_session(self) -> None:
|
||||||
"""Stop the current session."""
|
"""Stop the current session."""
|
||||||
self.session_active = False
|
self.session_active = False
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue