I think I found a problem on OpenGLContext with shouldPaintComponent set to true.
Quick creation/destruction sometime perform a null pointer indirection (CachedImage threading made this bug non systematics)
OpenGLContext::setAssociatedObject assert at line 619 before crash
with nativeContext not null but c null.
Here a snippet helping you to reproduce the problem :
[code]// dummy renderer
class VoidRenderer : public OpenGLRenderer
{
virtual void newOpenGLContextCreated() {}
virtual void renderOpenGL() {}
virtual void openGLContextClosing() {}
};
// Ugly component owning renderer and context with public attach/detach.
class VoidRendererAndContextComponent : public Component
{
public:
VoidRendererAndContextComponent()
{glContext.setComponentPaintingEnabled(true); glContext.setRenderer(&renderer);}
~VoidRendererAndContextComponent()
{jassert(!glContext.isAttached())}
void attach()
{glContext.attachTo(*this);};
void detach()
{glContext.detach();}
private:
VoidRenderer renderer;
OpenGLContext glContext;
};
// Todo: add a Timer inheritance to a Component class of your choice and a startThread(100) when it’s visible.
// …
// Trick to ensure !MessageManagerLock::lockWasGained() succeed on CachedImage::run() :
// I call creation-attachement / detachement-deletion alternately in a timerCallback
virtual void timerCallback()
{
static bool mustCreateAndAttach = false; // static alternator
mustCreateAndAttach = !mustCreateAndAttach ;
static VoidRendererAndContextComponent* component = NULL; // ugly static just for testing
if (mustCreateAndAttach)
{
component = new VoidRendererAndContextComponent();
component->setSize(42, 42);
addAndMakeVisible(component);
component->attach();
}
else // detach and delete
{
component->detach();
removeChildComponent(component);
delete component;
}
}
//…
// end of your Component class…[/code]