diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp index 166b7ef1a1..51e82c58b2 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandManager.cpp @@ -249,11 +249,13 @@ ApplicationCommandTarget* ApplicationCommandManager::findDefaultComponentTarget( if (c == nullptr && Process::isForegroundProcess()) { + Desktop& desktop = Desktop::getInstance(); + // getting a bit desperate now: try all desktop comps.. - for (int i = Desktop::getInstance().getNumComponents(); --i >= 0;) - if (ApplicationCommandTarget* const target = findTargetForComponent (Desktop::getInstance().getComponent (i) - ->getPeer()->getLastFocusedSubcomponent())) - return target; + for (int i = desktop.getNumComponents(); --i >= 0;) + if (ComponentPeer* const peer = desktop.getComponent(i)->getPeer()) + if (ApplicationCommandTarget* const target = findTargetForComponent (peer->getLastFocusedSubcomponent())) + return target; } if (c != nullptr) @@ -263,8 +265,8 @@ ApplicationCommandTarget* ApplicationCommandManager::findDefaultComponentTarget( // still be passed up to the top level window anyway, so let's send it to the // content comp. if (ResizableWindow* const resizableWindow = dynamic_cast (c)) - if (resizableWindow->getContentComponent() != nullptr) - c = resizableWindow->getContentComponent(); + if (Component* const content = resizableWindow->getContentComponent()) + c = content; if (ApplicationCommandTarget* const target = findTargetForComponent (c)) return target; diff --git a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp index c7e28d9f36..28d3b31649 100644 --- a/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp @@ -211,10 +211,8 @@ bool DirectoryContentsList::checkNextFile (bool& hasChanged) return true; } - else - { - fileFindHandle = nullptr; - } + + fileFindHandle = nullptr; } return false;