Hi,
Wavelab crashes because it gets stuck in an endless loop in juce_MessageManager (MessageManagerLock::init(…) at line 307) which is called in juce_VST_Wrapper::dispatcher(…)):
[code]void MessageManagerLock::init (Thread* const threadToCheck, ThreadPoolJob* const job) throw()
{
if (MessageManager::instance != 0)
{
if (MessageManager::instance->currentThreadHasLockedMessageManager())
{
locked = true; // either we’re on the message thread, or this is a re-entrant call.
}
else
{
if (threadToCheck == 0 && job == 0)
{
MessageManager::instance->lockingLock.enter();
}
else
{
while (! MessageManager::instance->lockingLock.tryEnter())
{
if ((threadToCheck != 0 && threadToCheck->threadShouldExit())
|| (job != 0 && job->shouldExit()))
return;
Thread::sleep (1);
}
}
SharedLockingEvents* const events = new SharedLockingEvents();
sharedEvents = events;
events->incReferenceCount();
(new MMLockMessage (events))->post();
while (! events->lockedEvent.wait (50)) //!!!!!!!!!!!!!!!!!!!!!!!! ENDLESS LOOP !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
{
if ((threadToCheck != 0 && threadToCheck->threadShouldExit())
|| (job != 0 && job->shouldExit()))
{
events->releaseEvent.signal();
events->decReferenceCount();
MessageManager::instance->lockingLock.exit();
return;
}
}
jassert (MessageManager::instance->threadWithLock == 0);
MessageManager::instance->threadWithLock = Thread::getCurrentThreadId();
locked = true;
needsUnlocking = true;
}
}
}
[/code]
This gets called in juce_VST_Wrapper at:
[code]VstIntPtr dispatcher (VstInt32 opCode, VstInt32 index, VstIntPtr value, void* ptr, float opt)
{
if (hasShutdown)
return 0;
if (opCode == effEditIdle)
{
doIdleCallback();
return 0;
}
else if (opCode == effEditOpen)
{
const MessageManagerLock mmLock;
jassert (! recursionCheck);
deleteEditor (true);
createEditorComp();
if (editorComp != 0)
{
editorComp->setOpaque (true);
editorComp->setVisible (false);
#if JUCE_WIN32
editorComp->addToDesktop (0);
hostWindow = (HWND) ptr;
HWND editorWnd = (HWND) editorComp->getWindowHandle();
SetParent (editorWnd, hostWindow);
DWORD val = GetWindowLong (editorWnd, GWL_STYLE);
val = (val & ~WS_POPUP) | WS_CHILD;
SetWindowLong (editorWnd, GWL_STYLE, val);
#elif JUCE_LINUX
editorComp->addToDesktop (0);
hostWindow = (Window) ptr;
Window editorWnd = (Window) editorComp->getWindowHandle();
XReparentWindow (display, editorWnd, hostWindow, 0, 0);
#else
hostWindow = attachComponentToWindowRef (editorComp, (WindowRef) ptr);
#endif
editorComp->setVisible (true);
return 1;
}
}
else if (opCode == effEditClose)
{
const MessageManagerLock mmLock;
deleteEditor (true);
return 0;
}
else if (opCode == effEditGetRect)
{
const MessageManagerLock mmLock; !!!!!!!!!!!!!!!!!!!!!!!!!!!!! LEADS TO ENDLESS LOOP IN MESSAGE MANAGER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
createEditorComp();
if (editorComp != 0)
{
editorSize.left = 0;
editorSize.top = 0;
editorSize.right = editorComp->getWidth();
editorSize.bottom = editorComp->getHeight();
*((ERect**) ptr) = &editorSize;
return (VstIntPtr) (pointer_sized_int) &editorSize;
}
else
{
return 0;
}
}
return AudioEffectX::dispatcher (opCode, index, value, ptr, opt);
}[/code]
I hope with this info it’s not that hard to fix the Wavelab crashes in the near future.
EDIT:
It works in other Steinberg hosts because it never gets to this point because
if (MessageManager::instance->currentThreadHasLockedMessageManager())
line 279 in juce_MessageManager returns true and in Wavelab it returns false.