Skip to content

Commit a9779b4

Browse files
committed
OpenGL: Fix missing buffered image after context detach
Prior to this commit a Component with setBufferedToImage (true) could have its image buffer deleted when an OpenGL context was detached. This meant that this Component continued to be rendered without buffering even though it was previously requested that it use a buffer.
1 parent ef54f01 commit a9779b4

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

modules/juce_gui_basics/detail/juce_ComponentHelpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
==============================================================================
3333
*/
3434

35+
#include "juce_ScalingHelpers.h"
36+
3537
namespace juce::detail
3638
{
3739

modules/juce_gui_basics/detail/juce_ScalingHelpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
==============================================================================
3333
*/
3434

35+
#pragma once
36+
3537
namespace juce::detail
3638
{
3739

modules/juce_opengl/opengl/juce_OpenGLContext.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
==============================================================================
3333
*/
3434

35+
#include <juce_gui_basics/detail/juce_ComponentHelpers.h>
36+
3537
#if JUCE_MAC
3638
#include <juce_gui_basics/native/juce_PerScreenDisplayLinks_mac.h>
3739
#endif
@@ -1102,19 +1104,12 @@ class OpenGLContext::Attachment final : public ComponentMovementWatcher,
11021104
detach();
11031105
}
11041106

1105-
static void clearCachedImagesInComponentTree (Component& root)
1106-
{
1107-
root.setCachedComponentImage (nullptr);
1108-
1109-
for (auto* child : root.getChildren())
1110-
clearCachedImagesInComponentTree (*child);
1111-
}
1112-
11131107
void detach()
11141108
{
11151109
auto& comp = *getComponent();
11161110
stop();
1117-
clearCachedImagesInComponentTree (comp);
1111+
detail::ComponentHelpers::releaseAllCachedImageResources (comp);
1112+
comp.setCachedComponentImage (nullptr);
11181113
context.nativeContext = nullptr;
11191114
}
11201115

0 commit comments

Comments
 (0)