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