Using removeFromDesktop() causes ApplicationCommandManager to crash

If you create a window, add it to the desktop and show it and then call removeFromDesktop(), the next time the ApplicationCommandManager processes a command it will crash.

ApplicationCommandTarget* ApplicationCommandManager::findDefaultComponentTarget()
{
    auto* c = Component::getCurrentlyFocusedComponent();

    if (c == nullptr)
    {
        if (auto* activeWindow = TopLevelWindow::getActiveTopLevelWindow())
        {
            c = activeWindow->getPeer()->getLastFocusedSubcomponent();

            if (c == nullptr)
                c = activeWindow;
        }
    }

Here it assumes the getActiveTopLevelWindow() has a valid peer, but it’s nullptr. Either this should check for nullptr, or when you call removeFromDesktop it should resign from being the active top level window.

Thanks, I’ll get that fixed.