From 9713794633210c34c9fd440c40190f976d39dafe Mon Sep 17 00:00:00 2001 From: pax Date: Mon, 13 Apr 2026 21:04:59 -0500 Subject: [PATCH] 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. --- booru_viewer/gui/popout/window.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/booru_viewer/gui/popout/window.py b/booru_viewer/gui/popout/window.py index 9ea0e35..68ce1bc 100644 --- a/booru_viewer/gui/popout/window.py +++ b/booru_viewer/gui/popout/window.py @@ -1777,4 +1777,14 @@ class FullscreenPreview(QMainWindow): # EmitClosed emits self.closed which triggers main_window's # _on_fullscreen_closed handler. 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)