AU Carbon UI deleteUI fix


#1

I noticed when doing a debug build an assert getting hit that juceFilter->editorBeingDeleted wasn’t being called and tracked it down the the carbon deleteUI call for AU.

This is the old code which only calls the single first child which just returns the editorCompHolder and not the audioProcessorEditor itself:

    void deleteUI()
    {
        if (windowComp != nullptr)
        {
            PopupMenu::dismissAllActiveMenus();

            /* This assertion is triggered when there's some kind of modal component active, and the\r
            host is trying to delete our plugin.\r
            If you must use modal components, always use them in a non-blocking way, by never\r
            calling runModalLoop(), but instead using enterModalState() with a callback that\r
            will be performed on completion. (Note that this assertion could actually trigger\r
            a false alarm even if you're doing it correctly, but is here to catch people who\r
            aren't so careful) */\r
            jassert (Component::getCurrentlyModalComponent() == nullptr);

            if (windowComp != nullptr && windowComp->getChildComponent(0) != nullptr)
                juceFilter->editorBeingDeleted ((AudioProcessorEditor*) windowComp->getChildComponent(0));

            windowComp = nullptr;
        }
    }

What is needed is a double call to the first child component like this:

    void deleteUI()
    {
        if (windowComp != 0)
        {
            PopupMenu::dismissAllActiveMenus();

            /* This assertion is triggered when there's some kind of modal component active, and the
               host is trying to delete our plugin.
               If you must use modal components, always use them in a non-blocking way, by never
               calling runModalLoop(), but instead using enterModalState() with a callback that
               will be performed on completion. (Note that this assertion could actually trigger
               a false alarm even if you're doing it correctly, but is here to catch people who
               aren't so careful) */
            jassert (Component::getCurrentlyModalComponent() == 0);

            EditorCompHolder* editorCompHolder = (EditorCompHolder*)windowComp->getChildComponent(0);
            if (editorCompHolder)
            {
                AudioProcessorEditor* audioProcessEditor = (AudioProcessorEditor*) editorCompHolder->getChildComponent(0);
                if (audioProcessEditor)
                {
                    juceFilter->editorBeingDeleted (audioProcessEditor);
                }
            }

            windowComp = 0;
        }
    }

#2

ah! Thanks very much, I’ll tidy that up!