diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index 50674ea337..9e3aa868d0 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -254,10 +254,13 @@ ApplicationCommandTarget* ApplicationCommandManager::findDefaultComponentTarget( { if (auto* activeWindow = TopLevelWindow::getActiveTopLevelWindow()) { - c = activeWindow->getPeer()->getLastFocusedSubcomponent(); + if (auto* peer = activeWindow->getPeer()) + { + c = peer->getLastFocusedSubcomponent(); - if (c == nullptr) - c = activeWindow; + if (c == nullptr) + c = activeWindow; + } } }