From cd48b711b436c9c8c390b8ccbb5fef3ff38c8e51 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 9 Jan 2012 20:31:38 +0000 Subject: [PATCH] Fix opengl errors when the file is modified with a minimized detached video window open Originally committed to SVN as r6257. --- aegisub/src/video_display.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index a64437340..0c133d255 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -140,10 +140,17 @@ VideoDisplay::~VideoDisplay () { } bool VideoDisplay::InitContext() { - if (!IsShownOnScreen()) return false; - if (!glContext.get()) { + if (!IsShownOnScreen()) + return false; + + // If this display is in a minimized detached dialog IsShownOnScreen will + // return true, but the client size is guaranteed to be 0 + if (GetClientSize() == wxSize(0, 0)) + return false; + + if (!glContext) glContext.reset(new wxGLContext(this)); - } + SetCurrent(*glContext.get()); return true; } @@ -183,7 +190,8 @@ void VideoDisplay::OnVideoOpen() { } void VideoDisplay::Render() try { - if (!InitContext() || !con->videoController->IsLoaded() || !videoOut) return; + if (!InitContext() || !con->videoController->IsLoaded() || !videoOut) + return; if (!viewport_height || !viewport_width) UpdateSize();