Hi Jules,
I can trigger (with some efforts) a crash in the 64-bit win vst version of my plugin. I'm using a quite old juce version , and cannot reproduce this issue in the juce demo plugin (it involves displaying an extra desktop window in addition to the plugin gui, showing/hiding them many times, it probably depends on a very precise time of event to trigger it). However, if you look at HWNDComponentPeer::performAnyPendingRepaintsNow :
if (component.isVisible()
&& (PeekMessage (&m, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE) || isUsingUpdateLayeredWindow()))
the ComponentPeer may be destroyed during the call to PeekMessage (this is what happens when my plugins crashes, its destructor is getting called during the PeekMessage call). And in that case, the call to isUsingUpdateLayeredWindow() triggers the crash , because the componentpeer is dead.
So I'm avoiding this crash using :
Component::SafePointer<Component> ptr(&component);
if (component.isVisible())
{
if (PeekMessage (&m, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE) ||
(ptr.getComponent() && isUsingUpdateLayeredWindow()))
{
handlePaintMessage();
}
}
I also have to edit the caller function doIdleCallback in juce_VST_Wrapper, as the loop on componentPeers is no more correct if some of them get deleted during the loop.
for (int i = ComponentPeer::getNumPeers(); --i >= 0;)
+ if (i < ComponentPeer::getNumPeers())
ComponentPeer::getPeer (i)->performAnyPendingRepaintsNow();
(this is an horrible fix , I know)
So, I can't say for sure that there is still a bug in juce 3 as I can't reproduce it with the juce demo, and my vst uses juce 30cc1ed7574f29a74113a83da8b76731f0a74555 from 2013/07/23 , but maybe what I said actually makes sense and there is still a possibility that a componentpeer gets destroyed in the middle of its performAnyPendingRepaintsNow function.
