Don't repeatedly try to initialize GLXLibrary. (Bug 605992) r=bjacob a2.0=joedrew
authorL. David Baron <dbaron@dbaron.org>
Wed, 10 Nov 2010 07:49:52 -0800
changeset 57245 8b500020522c2e00753f33e8458e5a01a6099da3
parent 57244 c8d35a82db4e945573dced69ee0d9730a0dd9514
child 57246 8b83d833cc950398c586183b23253ea9f4e3c59e
push id16847
push userdbaron@mozilla.com
push dateWed, 10 Nov 2010 15:50:38 +0000
treeherdermozilla-central@e250978a21be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs605992
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Don't repeatedly try to initialize GLXLibrary. (Bug 605992) r=bjacob a2.0=joedrew
gfx/thebes/GLContextProviderGLX.cpp
gfx/thebes/GLXLibrary.h
--- a/gfx/thebes/GLContextProviderGLX.cpp
+++ b/gfx/thebes/GLContextProviderGLX.cpp
@@ -67,16 +67,22 @@ static int gGLXVersion = 0;
 
 PRBool
 GLXLibrary::EnsureInitialized()
 {
     if (mInitialized) {
         return PR_TRUE;
     }
 
+    // Don't repeatedly try to initialize.
+    if (mTriedInitializing) {
+        return PR_FALSE;
+    }
+    mTriedInitializing = PR_TRUE;
+
     if (!mOGLLibrary) {
         mOGLLibrary = PR_LoadLibrary("libGL.so.1");
         if (!mOGLLibrary) {
 	    NS_WARNING("Couldn't load OpenGL shared library.");
 	    return PR_FALSE;
         }
     }
 
--- a/gfx/thebes/GLXLibrary.h
+++ b/gfx/thebes/GLXLibrary.h
@@ -40,17 +40,18 @@ typedef realGLboolean GLboolean;
 #include <GL/glx.h>
 
 namespace mozilla {
 namespace gl {
 
 class GLXLibrary
 {
 public:
-    GLXLibrary() : mInitialized(PR_FALSE), mOGLLibrary(nsnull) {}
+    GLXLibrary() : mInitialized(PR_FALSE), mTriedInitializing(PR_FALSE),
+                   mOGLLibrary(nsnull) {}
 
     typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
                                                           GLXContext);
     PFNGLXDESTROYCONTEXTPROC xDestroyContext;
     typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,
                                                        GLXDrawable,
                                                        GLXContext);
     PFNGLXMAKECURRENTPROC xMakeCurrent;
@@ -109,16 +110,17 @@ public:
                                                            GLXContext,
                                                            Bool);
     PFNGLXCREATECONTEXT xCreateContext;
 
     PRBool EnsureInitialized();
 
 private:
     PRBool mInitialized;
+    PRBool mTriedInitializing;
     PRLibrary *mOGLLibrary;
 };
 
 // a global GLXLibrary instance
 extern GLXLibrary sGLXLibrary;
 
 } /* namespace gl */
 } /* namespace mozilla */