From d9c2fd4a31d41f4ce1a2684f39852b98b1b76f46 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 2 Sep 2014 14:05:00 +0200 Subject: [PATCH] Bug 1059793 - Mark the compositor's gl context destroyed before the widget is gone. r=jgilbert --- gfx/gl/GLContext.h | 7 +++---- gfx/layers/opengl/CompositorOGL.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 5f811942d87..ed73c9b3181 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -2641,6 +2641,9 @@ protected: public: virtual ~GLContext(); + // Mark this context as destroyed. This will nullptr out all + // the GL function pointers! + void MarkDestroyed(); // ----------------------------------------------------------------------------- // Everything that isn't standard GL APIs @@ -2683,10 +2686,6 @@ public: virtual void ReleaseSurface() {} - // Mark this context as destroyed. This will nullptr out all - // the GL function pointers! - void MarkDestroyed(); - bool IsDestroyed() { // MarkDestroyed will mark all these as null. return mSymbols.fUseProgram == nullptr; diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index a6b22af7cdc..020d1bfa14e 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -173,6 +173,13 @@ CompositorOGL::CleanupResources() mQuadVBO = 0; } + // On the main thread the Widget will be destroyed soon and calling MakeCurrent + // after that could cause a crash (at least with GLX, see bug 1059793), unless + // context is marked as destroyed. + // There may be some textures still alive that will try to call MakeCurrent on + // the context so let's make sure it is marked destroyed now. + mGLContext->MarkDestroyed(); + mGLContext = nullptr; }