1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Component: Add function to clear all cached image resources

In the DemoRunner, switching to and fro between the Settings tab and
the Demo tab displaying the OpenGL demo could lead to
GL_INVALID_OPERATION errors. This is because closing the demo shuts
down the GL context, destroying resources such as framebuffers. If any
Image objects backed by framebuffers outlive the context, they will be
invalidated. Component effect images are especially likely to hold onto
invalid framebuffer references.

With this change in place, images cached by Components will be
invalidated when the attached GL context goes out of scope, and will be
recreated when the new context is created.
This commit is contained in:
reuk 2025-05-15 19:18:54 +01:00
parent bf54fb1fe9
commit 84eed04a59
No known key found for this signature in database
3 changed files with 18 additions and 2 deletions

View file

@ -237,8 +237,7 @@ struct ComponentHelpers
static void releaseAllCachedImageResources (Component& c)
{
if (auto* cached = c.getCachedComponentImage())
cached->releaseResources();
c.invalidateCachedImageResources();
for (auto* child : c.childComponentList)
releaseAllCachedImageResources (*child);