Browse Source

macOS: Removed all dynamic_cast type_info warning workarounds which have been fixed in 0dd3b02

tags/2021-05-28
ed 5 years ago
parent
commit
441c88f3b9
4 changed files with 58 additions and 83 deletions
  1. +5
    -9
      modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm
  2. +18
    -23
      modules/juce_graphics/native/juce_mac_Fonts.mm
  3. +4
    -8
      modules/juce_gui_basics/layout/juce_TabbedComponent.cpp
  4. +31
    -43
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp

+ 5
- 9
modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm View File

@@ -60,7 +60,11 @@ public:
CGColorSpaceRelease (colourSpace);
}
~CoreGraphicsPixelData() override;
~CoreGraphicsPixelData() override
{
freeCachedImageRef();
CGContextRelease (context);
}
std::unique_ptr<LowLevelGraphicsContext> createLowLevelContext() override
{
@@ -185,14 +189,6 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreGraphicsPixelData)
};
// The following implementation is outside of the class definition to avoid spurious
// warning messages when dynamically loading libraries at runtime on macOS
CoreGraphicsPixelData::~CoreGraphicsPixelData()
{
freeCachedImageRef();
CGContextRelease (context);
}
ImagePixelData::Ptr NativeImageType::create (Image::PixelFormat format, int width, int height, bool clearImage) const
{
return *new CoreGraphicsPixelData (format == Image::RGB ? Image::ARGB : format, width, height, clearImage);


+ 18
- 23
modules/juce_graphics/native/juce_mac_Fonts.mm View File

@@ -586,10 +586,24 @@ public:
CFRelease (numberRef);
}
// The implementation of at least one overridden function needs to be outside
// of the class definition to avoid spurious warning messages when dynamically
// loading libraries at runtime on macOS...
~OSXTypeface() override;
~OSXTypeface() override
{
if (attributedStringAtts != nullptr)
CFRelease (attributedStringAtts);
if (fontRef != nullptr)
{
#if JUCE_MAC && defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
if (dataCopy.getSize() != 0)
CTFontManagerUnregisterGraphicsFont (fontRef, nullptr);
#endif
CGFontRelease (fontRef);
}
if (ctFontRef != nullptr)
CFRelease (ctFontRef);
}
float getAscent() const override { return ascent; }
float getDescent() const override { return 1.0f - ascent; }
@@ -719,25 +733,6 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSXTypeface)
};
OSXTypeface::~OSXTypeface()
{
if (attributedStringAtts != nullptr)
CFRelease (attributedStringAtts);
if (fontRef != nullptr)
{
#if JUCE_MAC && defined (MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
if (dataCopy.getSize() != 0)
CTFontManagerUnregisterGraphicsFont (fontRef, nullptr);
#endif
CGFontRelease (fontRef);
}
if (ctFontRef != nullptr)
CFRelease (ctFontRef);
}
CTFontRef getCTFontFromTypeface (const Font& f)
{
if (auto* tf = dynamic_cast<OSXTypeface*> (f.getTypeface()))


+ 4
- 8
modules/juce_gui_basics/layout/juce_TabbedComponent.cpp View File

@@ -56,7 +56,10 @@ namespace TabbedComponentHelpers
//==============================================================================
struct TabbedComponent::ButtonBar : public TabbedButtonBar
{
ButtonBar (TabbedComponent& tabComp, TabbedButtonBar::Orientation o);
ButtonBar (TabbedComponent& tabComp, TabbedButtonBar::Orientation o)
: TabbedButtonBar (o), owner (tabComp)
{
}
void currentTabChanged (int newCurrentTabIndex, const String& newTabName)
{
@@ -83,13 +86,6 @@ struct TabbedComponent::ButtonBar : public TabbedButtonBar
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonBar)
};
// The following implementation is outside of the class definition to avoid spurious
// warning messages when dynamically loading libraries at runtime on macOS
TabbedComponent::ButtonBar::ButtonBar (TabbedComponent& tabComp, TabbedButtonBar::Orientation o)
: TabbedButtonBar (o), owner (tabComp)
{
}
//==============================================================================
TabbedComponent::TabbedComponent (TabbedButtonBar::Orientation orientation)
{


+ 31
- 43
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -55,7 +55,10 @@ struct HeaderItemComponent : public PopupMenu::CustomComponent
setName (name);
}
void paint (Graphics& g) override;
void paint (Graphics& g) override
{
getLookAndFeel().drawPopupMenuSectionHeader (g, getLocalBounds(), getName());
}
void getIdealSize (int& idealWidth, int& idealHeight) override
{
@@ -94,7 +97,13 @@ struct ItemComponent : public Component
addMouseListener (&parent, false);
}
~ItemComponent() override;
~ItemComponent() override
{
if (customComp != nullptr)
setItem (*customComp, nullptr);
removeChildComponent (customComp.get());
}
void getIdealSize (int& idealWidth, int& idealHeight, const int standardItemHeight)
{
@@ -264,7 +273,13 @@ struct MenuWindow : public Component
getMouseState (Desktop::getInstance().getMainMouseSource()); // forces creation of a mouse source watcher for the main mouse
}
~MenuWindow() override;
~MenuWindow() override
{
getActiveWindows().removeFirstMatchingValue (this);
Desktop::getInstance().removeGlobalMouseListener (this);
activeSubMenu.reset();
items.clear();
}
//==============================================================================
void paint (Graphics& g) override
@@ -998,7 +1013,14 @@ public:
startTimerHz (20);
}
void handleMouseEvent (const MouseEvent& e);
void handleMouseEvent (const MouseEvent& e)
{
if (! window.windowIsStillValid())
return;
startTimerHz (20);
handleMousePosition (e.getScreenPosition());
}
void timerCallback() override
{
@@ -1228,7 +1250,11 @@ struct NormalComponentWrapper : public PopupMenu::CustomComponent
addAndMakeVisible (comp);
}
void getIdealSize (int& idealWidth, int& idealHeight) override;
void getIdealSize (int& idealWidth, int& idealHeight) override
{
idealWidth = width;
idealHeight = height;
}
void resized() override
{
@@ -1243,44 +1269,6 @@ struct NormalComponentWrapper : public PopupMenu::CustomComponent
};
// The following implementations are outside of the class definitions to avoid spurious
// warning messages when dynamically loading libraries at runtime on macOS
void PopupMenu::HelperClasses::HeaderItemComponent::paint (Graphics& g)
{
getLookAndFeel().drawPopupMenuSectionHeader (g, getLocalBounds(), getName());
}
PopupMenu::HelperClasses::ItemComponent::~ItemComponent()
{
if (customComp != nullptr)
setItem (*customComp, nullptr);
removeChildComponent (customComp.get());
}
PopupMenu::HelperClasses::MenuWindow::~MenuWindow()
{
getActiveWindows().removeFirstMatchingValue (this);
Desktop::getInstance().removeGlobalMouseListener (this);
activeSubMenu.reset();
items.clear();
}
void PopupMenu::HelperClasses::MouseSourceState::handleMouseEvent (const MouseEvent& e)
{
if (! window.windowIsStillValid())
return;
startTimerHz (20);
handleMousePosition (e.getScreenPosition());
}
void PopupMenu::HelperClasses::NormalComponentWrapper::getIdealSize (int& idealWidth, int& idealHeight)
{
idealWidth = width;
idealHeight = height;
}
//==============================================================================
PopupMenu::PopupMenu (const PopupMenu& other)
: items (other.items),


Loading…
Cancel
Save