Skip to content

Commit cb34975

Browse files
committed
Fix crash after OpenGL::detach in the presence of buffered child components
The crash fixed by this commit could be triggered by attaching an OpenGL context to a component, calling setBufferedToImage (true) on one of its child components, and then detaching the OpenGL context from the parent. Since 4ba01a8 we are creating images with the current rendering context's native image type, so the above scenario would leave an image buffer that references the detached context.
1 parent 2da6a5f commit cb34975

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/juce_opengl/opengl/juce_OpenGLContext.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,11 +1102,19 @@ class OpenGLContext::Attachment final : public ComponentMovementWatcher,
11021102
detach();
11031103
}
11041104

1105+
static void clearCachedImagesInComponentTree (Component& root)
1106+
{
1107+
root.setCachedComponentImage (nullptr);
1108+
1109+
for (auto* child : root.getChildren())
1110+
clearCachedImagesInComponentTree (*child);
1111+
}
1112+
11051113
void detach()
11061114
{
11071115
auto& comp = *getComponent();
11081116
stop();
1109-
comp.setCachedComponentImage (nullptr);
1117+
clearCachedImagesInComponentTree (comp);
11101118
context.nativeContext = nullptr;
11111119
}
11121120

0 commit comments

Comments
 (0)