Pointer cast error in juce_amalgamated.cpp


#1

Just did a git pull this morning and just came up with this error (Mac, xcode).
#Error:: Invalid cast from juce::ScopedPointer to type AudioUnitPluginWindowCarbon* (or Cocoa, as below …)

Tried a dynamic_cast<> on the pointer instead, but no good. Wasn’t sure why that would be invalid, so I thought I would kick it up.

[code]
AudioProcessorEditor* AudioUnitPluginInstance::createEditor()
{
ScopedPointer w (new AudioUnitPluginWindowCocoa (*this, false));

     if (! ((AudioUnitPluginWindowCocoa*) w)->isValid())
	w = 0;

#if JUCE_SUPPORT_CARBON
if (w == 0)

	w = new AudioUnitPluginWindowCarbon (*this);

	if (! ((AudioUnitPluginWindowCarbon*) w)->isValid())
		w = 0;
}

#endif[/code]


#2

Thanks, I’ll tidy that up asap…


#3

looks like you’ve been making changes here. The pointer error is gone anyhow. And though loading the plugin and using it in my main audioCallback method seems fine (it processes audio) … I get this error when I try to view the plugin UI:

in juce_NSViewComponent.mm

void* NSViewComponent::getView() const { return info == 0 ? 0 : info->view; }

Thanks for all the hard work.


#4

um… what error?


#5

Sorry … EXC_BAD_ACCESS. So presumably info isn’t initialized to 0?


#6

info is a ScopedPointer - it’s automatically initialised to 0.
What’s the actual stack trace you’re getting?


#7

sure … the relevant portion is here:

Closing AU GUI: FM8 Closing AU GUI: FM8 Program received signal: “EXC_BAD_ACCESS”.

It doesn’t seem to always happen though. Certain plugins have issues more often that others. Perhaps something in the pluginInstance isn’t being allocated ?

Here is one that “worked”, it has issues as well … but I always figured that was the fault of the plugin
(I think I remember seeing those previously):

Closing AU GUI: 4Front Bass
Closing AU GUI: 4Front Bass
Closing AU GUI: 4Front Bass
Opening AU GUI: 4Front Bass
Closing AU GUI: 4Front Bass
Sat Mar 20 10:59:06 Aaron-Leeses-MacBook.local jucedemo[1496] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 489
Sat Mar 20 10:59:06 Aaron-Leeses-MacBook.local jucedemo[1496] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 489
Sat Mar 20 10:59:06 Aaron-Leeses-MacBook.local jucedemo[1496] <Error>: kCGErrorIllegalArgument: CGSOrderWindowList
Sat Mar 20 10:59:06 Aaron-Leeses-MacBook.local jucedemo[1496] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 489
Sat Mar 20 10:59:06 Aaron-Leeses-MacBook.local jucedemo[1496] <Error>: kCGErrorIllegalArgument: CGSRemoveWindowFromWindowOrderingGroup: Invalid window
Sat Mar 20 10:59:06 Aaron-Leeses-MacBook.local jucedemo[1496] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 489
Sat Mar 20 10:59:06 Aaron-Leeses-MacBook.local jucedemo[1496] <Error>: kCGErrorIllegalArgument: CGSRemoveWindowFromWindowMovementGroup: Invalid window
done removing a virtual instrument 

#8

I asked for a stack trace… You have actually tried catching this in the debugger, haven’t you?


#9

So you did, sorry. I should have backed up and sent you more.

No worries though, seems I got it … just a silly typo in juce_AudioPluginFormat.mm

[code]AudioProcessorEditor* AudioUnitPluginInstance::createEditor()
{
ScopedPointer w (new AudioUnitPluginWindowCocoa (*this, false));

if (! static_cast <AudioUnitPluginWindowCocoa*> (static_cast <AudioProcessorEditor*> (w))->isValid())
    w = 0;

#if JUCE_SUPPORT_CARBON
if (w == 0)
{
w = new AudioUnitPluginWindowCarbon (*this);

    if (! static_cast <AudioUnitPluginWindowCocoa*> (static_cast <AudioProcessorEditor*> (w))->isValid())
        w = 0;
}

#endif

if (w == 0)
    w = new AudioUnitPluginWindowCocoa (*this, true); // use AUGenericView as a fallback

return w.release();

} [/code]

the static cast within #if JUCE_SUPPORT_CARBON should be AudioUnitPluginWindowCarbon instead of Cocoa I believe. Which explains why some plugs worked out ok and others crashed.


#10

Drat! The cut-and-paste monster struck again!

Thanks for tracking that one down, I’ll get it sorted out right away…