Crash New Project Disabling Editor


I’m running JUCE 5.2.1

Generating a new Audio Plugin, Changing hasEditor to false, build & launching AU is causing a crash. You have to also set the getEditor function to return a nullptr and it works.

It’s all well and good, but worried it might confuse some students of mine.


This jassert in createEditorIfNeeded:

// You must make your hasEditor() method return a consistent result!
jassert (hasEditor() == (ed != nullptr));

Perhaps this is the desired functionality, I just wasn’t expecting it myself

I’d imagine something like?

if (ed != nullptr && hasEditor())
    // you must give your editor comp a size before returning it..
    jassert (ed->getWidth() > 0 && ed->getHeight() > 0);

    const ScopedLock sl (callbackLock);
    activeEditor = ed;

I don’t think we could have made the assert message any clearer!

And no, it definitely wouldn’t be a good idea to allow the two things to be inconsistent with each other.

There are two methods because hosts need to know in advance whether there’s a GUI.

And if the methods do different things then either:

a) You’ve written an editor and it won’t be shown, and you’re probably wondering why not
b) You’ve told the host there’s an editor but you haven’t written one, and that’s going to cause problems

Either way, an assertion is the correct thing to do to tell you that there’s a mistake in your code!

Ahh I see, I suppose I jumped the gun on this one.

I had never thought about assertions as a way guide user through inter-dependent functions like that :thinking:

I don’t think it did it in the past? Anyways I felt the cold fear of change breath down my neck lol

Thanks for the reply

I have built the AudioPluginHost for iOS > 9.3. If I try to load a AUnit, the plugin window gets blank. In the XCode debugger, the above mentioned assertion fails (it is called by the method “AudioProcessor::createEditorIfNeeded()”. I am not sure if this is an issue with AU and iOS. Anywais, when “hasEditor()” is called, the execution jumps into the code section #elif JUCE_SUPPORTS_AUv3 and then fails. Anyone can give me some light?

I think I was trying to load an AU inside iOS, and not a AUv3. So, this might explain the problem.

Just FTR, I think this thread doesn’t clarify the actual issue:

The hasEditor() is not the method to figure out, if there is currently an editor, but instead if the AudioProcessor is able to produce one at all.
I.e. the host will call this method to figure out, if it should show a button to show the editor.

If this returns true, createEditor() has to be overridden to return an instance of your AudioProcessorEditor. If hasEditor() returns false, you may just return nullptr in your createEditor(), and the host will usually show it’s own generic controls.

Ok. Many thanks for this explanation.