diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp index 3d2aed4dc9..2ff4156bba 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp @@ -59,14 +59,15 @@ LookAndFeel::~LookAndFeel() safe WeakReference to it, but it could cause some unexpected graphical behaviour, so it's advisable to clear up any references before destroying them! */ - jassert (masterReference.getNumActiveWeakReferences() == 0); + jassert (masterReference.getNumActiveWeakReferences() == 0 + || masterReference.getNumActiveWeakReferences() == 1 && this == &getDefaultLookAndFeel()); } //============================================================================== Colour LookAndFeel::findColour (int colourID) const noexcept { const ColourSetting c = { colourID, Colour() }; - const int index = colours.indexOf (c); + auto index = colours.indexOf (c); if (index >= 0) return colours.getReference (index).colour; @@ -78,7 +79,7 @@ Colour LookAndFeel::findColour (int colourID) const noexcept void LookAndFeel::setColour (int colourID, Colour newColour) noexcept { const ColourSetting c = { colourID, newColour }; - const int index = colours.indexOf (c); + auto index = colours.indexOf (c); if (index >= 0) colours.getReference (index).colour = newColour; @@ -128,16 +129,16 @@ void LookAndFeel::setDefaultSansSerifTypefaceName (const String& newName) //============================================================================== MouseCursor LookAndFeel::getMouseCursorFor (Component& component) { - MouseCursor m (component.getMouseCursor()); + auto cursor = component.getMouseCursor(); - Component* parent = component.getParentComponent(); - while (parent != nullptr && m == MouseCursor::ParentCursor) + for (auto* parent = component.getParentComponent(); + parent != nullptr && cursor == MouseCursor::ParentCursor; + parent = parent->getParentComponent()) { - m = parent->getMouseCursor(); - parent = parent->getParentComponent(); + cursor = parent->getMouseCursor(); } - return m; + return cursor; } LowLevelGraphicsContext* LookAndFeel::createGraphicsContext (const Image& imageToRenderOn, const Point& origin,