diff --git a/common/gl_context_mgr.cpp b/common/gl_context_mgr.cpp index af2863be36..125ed8fd11 100644 --- a/common/gl_context_mgr.cpp +++ b/common/gl_context_mgr.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 CERN + * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -78,7 +79,12 @@ void GL_CONTEXT_MANAGER::LockCtx( wxGLContext* aContext, wxGLCanvas* aCanvas ) m_glCtxMutex.lock(); wxGLCanvas* canvas = aCanvas ? aCanvas : m_glContexts.at( aContext ); - canvas->SetCurrent( *aContext ); + // Prevent assertion failure in wxGLContext::SetCurrent during GAL teardown + if( canvas->GetXWindow() ) + { + canvas->SetCurrent( *aContext ); + } + m_glCtx = aContext; }