From 2fb6b19e45cea0a27fb3068d4626d7542aa76289 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 4 Jul 2012 15:30:21 +0000 Subject: [PATCH] Destroy the old video context when detaching video It was previously not being destroyed until video was reattached, which wasted VRAM and caused problems on OS X. Originally committed to SVN as r6927. --- aegisub/src/dialog_detached_video.cpp | 9 +++++---- aegisub/src/video_display.cpp | 5 +---- aegisub/src/video_display.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/aegisub/src/dialog_detached_video.cpp b/aegisub/src/dialog_detached_video.cpp index 9f5109423..0572b730e 100644 --- a/aegisub/src/dialog_detached_video.cpp +++ b/aegisub/src/dialog_detached_video.cpp @@ -66,6 +66,8 @@ DialogDetachedVideo::DialogDetachedVideo(agi::Context *context) SetTitle(wxString::Format(_("Video: %s"), wxFileName(context->videoController->GetVideoName()).GetFullName())); + old_display->Unload(); + // Video area; VideoBox *videoBox = new VideoBox(this, true, context); context->videoDisplay->SetMinClientSize(old_display->GetClientSize()); @@ -103,17 +105,16 @@ DialogDetachedVideo::DialogDetachedVideo(agi::Context *context) DialogDetachedVideo::~DialogDetachedVideo() { } void DialogDetachedVideo::OnClose(wxCloseEvent &evt) { - // Deleting a GL context seems to invalidate ALL contexts, so we need to - // delete both the detached and undetached contexts here, then recreate - // the undetached one later context->videoDisplay->Destroy(); - old_display->Reload(); context->videoDisplay = old_display; context->videoSlider = old_slider; OPT_SET("Video/Detached/Enabled")->SetBool(false); + if (context->videoController->IsLoaded()) + context->videoController->JumpToFrame(context->videoController->GetFrameN()); + evt.Skip(); } diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index 4c9335050..97aa08d16 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -420,11 +420,8 @@ Vector2D VideoDisplay::GetMousePosition() const { return mouse_pos ? tool->ToScriptCoords(mouse_pos) : mouse_pos; } -void VideoDisplay::Reload() { +void VideoDisplay::Unload() { glContext.reset(); videoOut.reset(); tool.reset(); - - if (con->videoController->IsLoaded()) - con->videoController->JumpToFrame(con->videoController->GetFrameN()); } diff --git a/aegisub/src/video_display.h b/aegisub/src/video_display.h index 05a8b911b..05b032a49 100644 --- a/aegisub/src/video_display.h +++ b/aegisub/src/video_display.h @@ -171,5 +171,5 @@ public: bool ToolIsType(std::type_info const& type) const; /// Discard all OpenGL state - void Reload(); + void Unload(); };