popout: explicit mpv cleanup on close to free VRAM

FullscreenPreview has no WA_DeleteOnClose and Qt's C++ dtor does
not reliably call Python-side destroy() overrides once
popout_controller drops its reference, so the popout's separate
mpv instance + NVDEC surface pool leaked until the next full
Python GC cycle. closeEvent now calls _gl_widget.cleanup()
explicitly after the state machine's CloseRequested dispatch.

behavior change from v0.2.6: popout open/close cycles no longer
stair-step VRAM upward; the popout's mpv is torn down immediately
on close instead of waiting on GC.
This commit is contained in:
pax 2026-04-13 21:04:59 -05:00
parent 860c8dcd50
commit 9713794633

View File

@ -1777,4 +1777,14 @@ class FullscreenPreview(QMainWindow):
# EmitClosed emits self.closed which triggers main_window's # EmitClosed emits self.closed which triggers main_window's
# _on_fullscreen_closed handler. # _on_fullscreen_closed handler.
self._dispatch_and_apply(CloseRequested()) self._dispatch_and_apply(CloseRequested())
# Tear down the popout's mpv + GL render context explicitly.
# FullscreenPreview has no WA_DeleteOnClose and Qt's C++ dtor
# doesn't reliably call Python-side destroy() overrides once
# popout_controller drops its reference, so without this the
# popout's separate mpv instance + NVDEC surface pool leak
# until the next full Python GC cycle.
try:
self._video._gl_widget.cleanup()
except Exception:
pass
super().closeEvent(event) super().closeEvent(event)