From e91def7fae80c4444796a7faf2ca50a495f06408 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 15 May 2018 12:03:20 +0100 Subject: [PATCH] OpenGL: Fixed an issue where components using OpenGL would not be restarted correctly when used in the FX docker window in Reaper --- .../native/juce_mac_NSViewComponentPeer.mm | 22 +++++++++---------- modules/juce_opengl/native/juce_OpenGL_osx.h | 10 --------- .../juce_opengl/opengl/juce_OpenGLContext.cpp | 11 ---------- .../juce_opengl/opengl/juce_OpenGLContext.h | 4 ---- 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 39a61b4bf9..0af2abee71 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -64,10 +64,6 @@ static NSRect flippedScreenRect (NSRect r) noexcept return r; } -#if JUCE_MODULE_AVAILABLE_juce_opengl -void componentPeerAboutToChange (Component&, bool); -#endif - //============================================================================== class NSViewComponentPeer : public ComponentPeer, private Timer @@ -705,12 +701,8 @@ public: void redirectWillMoveToWindow (NSWindow* newWindow) { - #if JUCE_MODULE_AVAILABLE_juce_opengl - if ([view window] == window) - componentPeerAboutToChange (getComponent(), newWindow == nullptr); - #else - ignoreUnused (newWindow); - #endif + if ([view window] == window && newWindow == nullptr) + getComponent().setVisible (false); } void sendMouseEvent (NSEvent* ev) @@ -1046,7 +1038,15 @@ public: void viewMovedToWindow() { if (isSharedWindow) - window = [view window]; + { + auto* newWindow = [view window]; + bool shouldSetVisible = (window == nullptr && newWindow != nullptr); + + window = newWindow; + + if (shouldSetVisible) + getComponent().setVisible (true); + } } void liveResizingStart() diff --git a/modules/juce_opengl/native/juce_OpenGL_osx.h b/modules/juce_opengl/native/juce_OpenGL_osx.h index dd1784f533..67aeb2bf36 100644 --- a/modules/juce_opengl/native/juce_OpenGL_osx.h +++ b/modules/juce_opengl/native/juce_OpenGL_osx.h @@ -249,14 +249,4 @@ bool OpenGLHelpers::isContextActive() return CGLGetCurrentContext() != 0; } -//============================================================================== -void componentPeerAboutToChange (Component& comp, bool shouldSuspend) -{ - if (auto* context = OpenGLContext::getContextAttachedTo (comp)) - context->overrideCanBeAttached (shouldSuspend); - - for (auto* child : comp.getChildren()) - componentPeerAboutToChange (*child, shouldSuspend); -} - } // namespace juce diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index 85d69eb91f..f68fb96912 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -1055,17 +1055,6 @@ void OpenGLContext::execute (OpenGLContext::AsyncWorker::Ptr workerToUse, bool s jassertfalse; // You must have attached the context to a component } -void OpenGLContext::overrideCanBeAttached (bool newCanAttach) -{ - if (overrideCanAttach != newCanAttach) - { - overrideCanAttach = newCanAttach; - - if (auto* a = attachment.get()) - a->update(); - } -} - //============================================================================== struct DepthTestDisabler { diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.h b/modules/juce_opengl/opengl/juce_OpenGLContext.h index ef5e15edf0..ed696a46b4 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.h +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.h @@ -349,10 +349,6 @@ private: JUCE_DECLARE_NON_COPYABLE (AsyncWorkerFunctor) }; - //============================================================================== - friend void componentPeerAboutToChange (Component&, bool); - void overrideCanBeAttached (bool); - //============================================================================== CachedImage* getCachedImage() const noexcept; void execute (AsyncWorker::Ptr, bool);