diff --git a/modules/juce_opengl/native/juce_OpenGL_linux_X11.h b/modules/juce_opengl/native/juce_OpenGL_linux_X11.h index 9de02cb283..e5524769bd 100644 --- a/modules/juce_opengl/native/juce_OpenGL_linux_X11.h +++ b/modules/juce_opengl/native/juce_OpenGL_linux_X11.h @@ -154,6 +154,7 @@ public: void shutdownOnRenderThread() { + ScopedXLock xlock (display); context = nullptr; deactivateCurrentContext(); glXDestroyContext (display, renderContext); @@ -162,23 +163,27 @@ public: bool makeActive() const noexcept { + ScopedXLock xlock (display); return renderContext != 0 && glXMakeCurrent (display, embeddedWindow, renderContext); } bool isActive() const noexcept { + ScopedXLock xlock (display); return glXGetCurrentContext() == renderContext && renderContext != 0; } static void deactivateCurrentContext() { ScopedXDisplay xDisplay; + ScopedXLock xlock (xDisplay.display); glXMakeCurrent (xDisplay.display, None, 0); } void swapBuffers() { + ScopedXLock xlock (display); glXSwapBuffers (display, embeddedWindow); } @@ -202,6 +207,7 @@ public: if (auto GLXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) OpenGLHelpers::getExtensionFunction ("glXSwapIntervalSGI")) { + ScopedXLock xlock (display); swapFrames = numFramesPerSwap; GLXSwapIntervalSGI (numFramesPerSwap); return true;