1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

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 4ba01a80a0 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.
This commit is contained in:
attila 2025-10-22 17:00:48 +02:00 committed by Attila Szarvas
parent 2da6a5fb62
commit cb34975457

View file

@ -1102,11 +1102,19 @@ public:
detach();
}
static void clearCachedImagesInComponentTree (Component& root)
{
root.setCachedComponentImage (nullptr);
for (auto* child : root.getChildren())
clearCachedImagesInComponentTree (*child);
}
void detach()
{
auto& comp = *getComponent();
stop();
comp.setCachedComponentImage (nullptr);
clearCachedImagesInComponentTree (comp);
context.nativeContext = nullptr;
}